2

As we knew, in classic view folder and report are in a two-level structure. We can not create folder under folder in classic mode.

Using SOQL like (Select OwnerId,Id from Report / Select from Folder), we can get reports and folders, and display them in flat view.

Lightning has enabled nested folders as new feature. So it seems that the folder-report is no longer a flat structure.

Can we get this kind of relationship by SOQL?

1 Answer 1

0

It's not yet documented in the Folder field reference, but there is now a ParentId field on the Folder sObject, with child relationship name SubFolders:

relationship view

This means you can do

SELECT Id, Name, (SELECT Id, Name FROM SubFolders) FROM Folder

or

SELECT Id, Name, ParentId FROM Folder 

and get back details of the hierarchy. Unfortunately, Salesforce doesn't let you traverse the Parent relationship using dot notation, for reasons I don't know:

SELECT Id, Name, Parent.Name FROM Folder 

yields

ERROR at Row:1:Column:18 Didn't understand relationship 'Parent' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

You must log in to answer this question.

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