function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Joel RJoel R 

Error Occurred: java.lang.NullPointerException from Email Alert using Visualforce Email Template

Hello fellow SF Developers,

We are experiencing an issue where an Email Alert using a Visualforce Email Template does not work from either a workflow or Process Builder process when the user executing is a Site user.

The Site user definitely has the necessary object permissions needed for the Visualforce Email template, and the Email Template does not call on any Apex controller.

If I remove any dynamic merging code, the error doesn’t occur. The following VF Email Template works just fine:
<messaging:emailTemplate subject="Test" relatedToType="pba__Request__c">
<messaging:htmlEmailBody >
<html><body>Test</body></html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>



But as soon as I add any reference to a merge field to the template (e.g. "{!relatedTo.Id}", the error occurs:
<messaging:emailTemplate subject="{!relatedTo.Id}" relatedToType="pba__Request__c">
<messaging:htmlEmailBody >
<html><body>Test</body></html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

When a Process Builder calls the Email Alert, I get an error saying "Error Occurred: java.lang.NullPointerException"

Has anyone experienced this before, or can suggest things to troubleshoot and find the root cause?
Khan AnasKhan Anas (Salesforce Developers) 
Hi Joel,

Greetings to you!

I tried to research your problem and found that this is a known issue. Keep watching this issue until get fixed.

https://success.salesforce.com/issues_view?id=a1p3A000000312nQAA

You can select the 'This Issue Affects Me' button to report your account and receive updates.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Joel RJoel R

Hi Khan,

You legend, thank you so much!
I searched pretty comprehensively to see if someone else had the issue, but couldn't find anything. 

I'll monitor this issue closely.
 

Thanks again.
 

Cheers,
Joel