I am trying to create a template that reports on the user record details. However I run into an issue when I create an email alert form a workflow that is triggered when a new user record is created. I want to pass the user details through to the template, however the template display the user details of the running user of the workflow. Is there a way around this?
2 Answers
To reference the target user record, I should use {!Target_User.[FIELD]} where [FIELD] is the field name. Link
It is worth to consider setting up a trigger on your object and send an email from within it. This way you can parse the template on your own in Apex, like:
string subject = template.Subject;
string body = template.HtmlValue;
subject = subject.replace('{my_tag}', 'my value');
body = body.replace('{another_tag}', 'some value');
-
3slightly too complex a solution for what we need. I always try to build in Salesforce through point and click rather than code but thanks for your answer.– BartleyCommented Apr 22, 2015 at 8:51