function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gliugliu 

Access to the default, public folder object?

Folks,

 

I've run into a strange quirk with folders and am looking for some ideas/input. 

 

If one were to create a few email templates that do not belong to any particular folder, those templates would be filed under the "public" folder. Querying via SOQL or IDE schema browser would then return the templates with what looks like valid "folderid" values. The problem is, that folder Id (I'm assuming it's the default public one) doesn't seem to be query-able via SOQL or IDE browser. Creating any number of any other folders and filing email templates under them works fine and the email templates point to folders that are query-able.

 

Is there something I'm missing here? What's the trick to querying for the default, public folder?

 

Thanks,

Grant

Ispita_NavatarIspita_Navatar

You are doing nothing wrong the public folder is not exposed for SOQL querying to support please check the attached query:-


 folderMap = new Map<Id, Folder>( [Select id , name from Folder where Type = 'Email']);


This returns the list of all the folders of email templates but not the public folder.


You can query email templates as per the attached query:-


[select name, TemplateType, Description, FolderId from EmailTemplate ];


then use the folder ids in the first query of folder  to find those which are within custom folders and the rest will be those which are in the public folder.

 

Hope this solves your query.