+ Start a Discussion

DML not allowed on EmailTemplate?

I tried to create an EmailTemplate in apex but got the message "Save Error: DML not allowed on EmailTemplate".  Is there a reason we cannot create or update email templates in apex now or any other way to do this?
Had same issue last year and it was escalated with SFDC support. Here is the final response
We're able to reproduce this issue and it is most likely expected behavior, but please could you provide us what your business reason is for wanting to create or update EmailTemplates with Apex Code.

We can send this on to the PM to position this as a feature request (to open up access to these tables) or as a documentation error (add EmailTemplate to the list of objects that do not accept DML statements).

Should you have further questions please let me know.

By the time this response was received we had already reimplemented the functionality without creation of EmailTemplate and hence did not bother to explain the use case because it did not seem like it would change anything in the near future.

So, I guess it should be considered as a bug in the documentation rather than in the actual system, i.e. documentation should not say than EmailTemplates can be created using API.
Rasmus MenckeRasmus Mencke
We will look into the issue. According to our API documentation DML's are allowed. My test showed DML's are not allowed. Will update with more information when I get some more details.
Any update on this issue ?
Preetisoni DebiduttaPreetisoni Debidutta
Same for me..But,for me its EmailServicesAddress  object.I have implemented this in my apex code but when i insert the same in test class i get this error-"DML operation Insert not allowed on EmailServicesAddress".I found that we cannot DML on that  from this link - "https://success.salesforce.com/ideaView?id=08730000000KlHZAA0"
So   I guess I'll have to use Apex to call the API to meet the business requirement.