Short story: What is the best way to query for a list of reports in the 'Unfiled Public Report' folder.
Long story:
When I want to get a list of reports from a specific folder in apex I make a SOQL query like this:
SELECT Id,Name FROM Report WHERE OwnerId = :folderId
When I want a list of reports from Unfiled Public Reports in apex how would I do that? As far as I know Unfiled Publif Reports doesn't have a folder id.
I was able to get a list of reports by using the OwnerId of the organization. Like this:
SELECT Id,Name FROM Report WHERE OwnerId = :OrgID
Only was able to find that from this question about setting owner.
Turns out the OwnerId is a great way to get the list. Using the way of getting the OrgId programmatically from frontendloader my code turned out like this.
[SELECT Id,Name from Report WHERE OwnerID = :UserInfo.getOrganizationId()];
Interesting note: Found an answer on the Salesforce IdeaExchange from 5 years ago that talks about the folder name being unfiled$public
but I am unable to get that to work. Also can't find confirmation of that. Only see it in unrelated source code here.