+ Start a Discussion

Trying to query EmailTemplate and BrandTemplate in one statement

I'm attempting to get the BrandTemplate along with the EmailTemplate in a single statement, instead of two.

I have a function that takes the EmailTemplateID, and I query the EmailTemplate information, including the BrandTemplateID. Then I Query the value of the BrandTemplate using the BrandTemplateID. But I want to make that into a single statement, to save on queries.


I know I can do this to get Owner information on an object such as an Account when it has OwnerId:

Account theAcc = [Select Name, ID, Owner.Name, From Account Where ID = '...'];


Since the EmailTemplate has BrandTemplateID, I suspect I could do this:

        EmailTemplate ET = [SELECT ID, Name, FolderID,Folder.Name, ApiVersion , Body , 
                            Description ,DeveloperName , Encoding , 
                            HtmlValue , IsActive, Markup, NamespacePrefix , OwnerID, 
                            Subject, TemplateStyle, TemplateType,
                            FROM EmailTemplate WHERE ID = :EmailTemplateID  ];


But it says that it doesn't understand relationship BrandTemplate.


Not all parent-child relationships are exposed in SOQL. If you look at your enterprise WSDL, the relationship name for BrandTemplate does not exist.