Can I use more than one “USING SCOPE” clause?

I am using this query to get a list of old reports in private folders and I am wondering if I can include public folders also. Here is the query:

SELECT Id,name,LastRunDate,owner.firstname,foldername,,owner.isactive FROM Report USING SCOPE allPrivate WHERE LastRunDate < LAST_N_DAYS:365

If I use “USING SCOPE everything” I get a list of report in public folders. I want to combine these into one report.

Can I use more than one scope like this? USING SCOPE everything AND allPrivate


As suggested by @cropredy, rolling up comments as an answer.

Looking at the SOQL Syntax, it doesn’t seem you can join different filterScope values. The AND keyword can be only used when you are utilizing that in WHERE clause.

SELECT fieldList [subquery][...]
[TYPEOF typeOfField whenExpression[...] elseExpression END][...]
FROM objectType[,...] 
    [USING SCOPE filterScope]
[WHERE conditionExpression]

<<other clauses removed for readability>>

Source : Link , Question Author : Andy Shelton , Answer Author : Jayant Das

Leave a Comment