1

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:

  1. List all the folders using @ashwani

  2. Rerun listmetadata() by setting the folder names from step 1 and type = 'EmailTemplate'.

1 Answer 1

1

There is an Exception:-

You need set Folder name instead of Email Template for Metadata as:

MetadataService.ListMetadataQuery queryEmailFolder= new MetadataService.ListMetadataQuery();
// Define Folder Name ''
queryEmailFolder.folder = '';
// Set EmailFolder
queryEmailFolder.type_x = 'EmailFolder';
queries.add(queryEmailFolder);       
MetadataService.FileProperties[] fileProperties = service.listMetadata(queries, 30);
2
  • Thanks @Ashwani. This returns metadata for folders when I query using package.xml with 'EmailTemplate' 'FolderLists'. How can I retrieve .email files using metadata API?
    – dmachop
    Mar 15, 2016 at 17:44
  • 1
    I've found the solution. List all the folders using your solution and then run another listmetadata() for each folder name with type 'EmailTemplate'.
    – dmachop
    Mar 16, 2016 at 18:50

You must log in to answer this question.

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