[SalesForce] TEMPLATE_NOT_FOUND When workflow is fired from Communties

In a partner community I have a button which users click to accept a request. On the click of this button I perform an update on a record, which then causes it to meet some workflow criteria. At this point a email alert should be fired. Unfortunately the email isn't received and I see the following error being thrown in the logs:

TEMPLATE_NOT_FOUND, The record couldn't be saved because it triggered an email alert that failed. Please contact salesforce.com Customer Support.

In the error it displays the template Id. The template it refers to is a Visualforce template which has previously been pushed across in a change set. This same workflow and email alert are working in a different environment. I have checked security and ensured that all the fields referenced in the template are accessible to the community user. Additionally I have checked that the data in the template is valid. If the email is triggered from the standard sf UI (e.g. I update a field, which causes the wf rule to be valid) the email alert and template work just fine. Can anyone shine a light on a solution for this?

EDIT
Interestingly commenting out all the merge fields in the VF template allows the email to fire successfully.

Best Answer

We found that this error was being caused, by the referenced records not being shared. We figured this out by turning all related objects referenced in the template to public read sharing, which fixed the issue. Then we back tracked through the objects and created sharing rules to share with the appropriate user.

EDIT We queried the UserRecordAccess Object to determine if our community users had access to the records referenced in the templates which helped us to narrow down the objects which weren't shared or didn't have read access for that community profile.

Related Topic