Skip to content

kloudingenuity/EmailTemplatesforCustomEntities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Description

Email templates save time when creating multiple email messages. Email templates contain prefilled data that we specify, so we don’t have to reenter the same information again. Specifying dynamic values from out of the box entities is pretty simple but there are some instances when we might want to add dynamic values for custom entities. To which we don’t have any straightforward approach in CRM as we cannot add custom entity in email template.

This solution is designed to address the above stated problem. It uses Global Templates and a workaround approach to define custom entity attributes within the template. This can be installed using standard CRM import process.

Define Email Template for Custom Entity

  1. Create an email template by selecting Template Type as Global.
  2. KLI_01.png
  3. Define dynamic values of custom entity using the pattern {!<Entity Logical Name>:<Attribute Logical Name>; <Default Value>}. Default value is optional in this pattern. When Attribute value is null it will be replaced with Default Value.

    Eg: {!new_customentity:new_customattribute;Default Text}

    Defining the text fields are easy enough and above pattern works for most of the field types. Refer below table for complex field types.
    KLI_02.png
  4. Define dynamic values of related entities (for the Custom Entity defined in step-3) using the pattern {!Related!<Primary Attribute Logical Name>:<Related Attribute Logical Name>; <Default Value>}

    Eg: {!Related!PrimaryContactId:EmailAddress1;sample@sample.com}

  5. There could be some scenarios where we might have to set some dynamic values which might not be coming from Primary/Related entities. In such case define the values using the pattern {!Custom:<Label>;}. The value for this will be specified in the workflow activity.

    Eg: {!Custom:Description;}

Send Email using Template

Send Email using the Custom Workflow Activity:
Our solution provides a custom workflow activity “SendEmail” which can be called from any CRM process.

  1. Add Send Email step in the process.
  2. KLI_03.png
  3. KLI_04.png
  4. Define properties for the Send Email step.
  5. KLI_05.png
  6. KLI_06.png

Send Email using the custom Action

Our solution provides a custom action “kli_SendEmail” which can be called from JavaScript, Plugins, custom applications etc. This action internally uses the same custom workflow activity that described earlier.

Arguments for Action:

KLI_07.png
This custom action takes three required input arguments. Apart from these three arguments pass Primary entity as Target argument.
KLI_08.png

Sample JavaScript to define input parameters:

KLI_09.png

This custom action will return three parameters.
KLI_10.png

Limitations

  1. Currently this solution supports only one level of relationship. To get the grandchild values are not possible using the pattern defined. Only parent and child are possible.