My QA users have overfloaded the Developer Sandbox with 234 MB of files. I try to wipe all the content, however, looks like SOQL query doesn't return all the files even though I can see them in UI. I need to query content document which are shared with the current user on UI but not shared with the current user on the SOQL. How can I achieve that and wipe the content on the sandbox?

I tried to use the following code

    List<ContentDocument> content = [select id from ContentDocument WHERE ContentAssetId  = null];
    delete content;

However, it didn't help to wipe content.

Also, if I try to use USING SCOPE optional clause with allPrivate

Select Id, Title From ContentDocument USING SCOPE allPrivate

it fails with an error

[INVALID_QUERY_SCOPE] Invalid query scope: allPrivate

1 Answer 1


There are several solutions.

  1. Refresh sandbox from production.

  2. Create a permission set QueryAllFiles and enabled checkbox Query All Files in App permissions section. Then rerun your code and it should work.

Also, created an idea about this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .