Button to open email with template already inserted

0
26
Forum Post: Change the Filter On option on Opportunity Associated View for Account form


The accepted answer worked great for me. However in order to get the email body (description) to populate from the template on page load, I had to pass an empty string (with a space) as the description parameter. Here is my final solution:

       //Set template lookup parameter to pass to email

       var template = {

           id: {email template id},

           name: {email template name},

           entityType: “template”

       };

       //Set regardingobjectid lookup

       var regardingLookup = {

           id: formContext.data.entity.getId().replace(/[{}]/g, ”),

           name: formContext.data.entity.getPrimaryAttributeValue(),

           entityType: “incident”

       };

       var parameters = {

           formId: emailFormId,

           regardingobjectid: regardingLookup,

           templateid: template,

           description: ” ” // Here is where I had to add an empty description (must have space character)

       };

       var entityFormOptions = {};

       entityFormOptions[“entityName”] = “email”;

       Xrm.Navigation.openForm(entityFormOptions, parameters);



Source link

Leave a reply

Please enter your comment!
Please enter your name here