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

Load emailTemplate body with field merging completed in field the user can then edit

From what I read on the boards this is not possible because the "merging" happens when the email is actually sent based on WhatId and TargetObjectId and objects related to those objects.


I still need to get this done but before I write something the hard way does anyone have any feedback on what im thinking i need to do?


here is what i am thinking i need to do.


- when the script initializes i do a field describe on the objects it set up for the whoId and TargetObjectId

- i map the field names to the values returned from the query

- get the body from the email template

- parse through the body to find the merge fields looking for "X" inside the merge values "{!X}".

- replace X with the value from the map , matching by field name


doesnt that sound like it will accomplish what i want?


please provide feedback.


thank you.

Shashikant SharmaShashikant Sharma

Seems correct approach to me as adding merge fields using whatId and targetObjectId is only availabel for some objects. I also did same thing when i needed to send mail where target object was a custom object and I was sending mail via Apex Code.