I was able to retrieve metadata for DashboardFolders using listMetadata(). However, the same does not apply for EmailTemplates where it returns empty. The inference from this thread is that it is not possible and can only be achieved from the query
SELECT DeveloperName FROM Folder WHERE Type = 'Email'
There should be a way since the documentation explicitly states that this can be queried. Quoting the doc:
You can’t use the wildcard (*) symbol with email templates in package.xml. To retrieve the list of email templates for populating package.xml with explicit names, call listMetadata() and pass in EmailTemplate as the type.
Are there any permissions that has to be set while retrieving the EmailTemplate folders? Additionally, there could be the default templates that are listed: SupportCaseAssignmentNotification, Support*, SalesNewCustomerEmail. There are around 13 of them. The above query does not include these. I can run a query on EmailTemplate:
SELECT DeveloperName, Body from EmailTemplate
How different is this from retrieving using Metadata API where SOAP API already satisfies by using one query whereas Metadata API could be invoked using list + retrieve calls (wrt EmailTemplates) ?
- UPDATE:
The solution is to:
List all the folders using @ashwani
Rerun listmetadata() by setting the folder names from step 1 and type = 'EmailTemplate'.