1

When I query for only a folder in Email Templates with this SOQL

SELECT FolderName,Name 
FROM EmailTemplate 
WHERE FolderName = 'Customer Returns

I get no data. However if I leave out the WHERE statement. I can see those Folders.
Customer Returns Mismatched Order Ltr w URL Lee

5

This is a really strange behavior.

Below query you mentioned in the question didn't work for me as well:

SELECT Name, FolderName FROM EmailTemplate WHERE FolderName = 'Customer Returns'

But apparently when we change FolderName to Folder.Name in the where clause, the query works:

SELECT Name, FolderName FROM EmailTemplate WHERE Folder.Name = 'Customer Returns'

I don't know why this works, looks like a bug to me.

3
  • 1
    I think FolderName is meant to be used only to display the value. Folder.Name is definitely the way I would query this.
    – sfdcfox
    Sep 11 '20 at 0:05
  • 1
    Thanks for the reply @sfdcfox, looking at the documentation of the EmailTemplate object, FolderName does has Filter property, so ideally filtering by FolderName should have also worked?
    – Raul
    Sep 11 '20 at 0:07
  • 1
    Yeah, it should. Perhaps a bug of some sort? I just did a test, apparently FolderName has a lower query cost than folder.name. It might be worth logging a case with Technical Support.
    – sfdcfox
    Sep 11 '20 at 0:40
0

Filter.Name works - I don't know why either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.