Views:

Scenario Overview

In this scenario we are demonstrating how to use N52 BPA to create Template emails in CRM, and use both parameters and dynamic data slugs to populate the emails.

This will allow you to add information to emails using parameters passed like {0}, {1} etc. from within the formula and information like [account.name], [incident.ticketnumber] from inside the template email itself.

For this example we will use a custom entity type called test1, however you can use this functionality with any entity in CRM.

The test1 entity has an N:1 relationship with the account entity.

Using the [syntax] functionality within the template you can reach across N:1 relationships and return data.
[new_test1.new_accountid.creditlimit.#] (see the notes on Syntax below) will retrieve the credit limit from the parent account connected with the test1 entity.


Global Template

N52 Formula Manager Solution

The Formula Manager solution works like this:

  • Formula of type 'Save - Perform Action' is set up on the test1 entity
  • The Formula creates the email using the template name and the language code.
  • Then it sends the email out to the customer


N52 Formula

Resulting Email


Formula

 SmartFlow(
          
         SetVar('TemplateID', FindTemplateId('Shannon Test One', '1033')),

          SetVar('EmailID', CreateEmailFromTemplate(GetVar('TemplateID'),
                                     WhoAmI(),
                                     'systemuser',
                    SetAttributePartyList('from','systemuser', 
                                           WhoAmI()), 
                    SetAttributePartyList('to','systemuser', 
                                          [new_test1.ownerid]), 
                    SetAttributeLookup('regardingobjectid','new_test1', 
                                       [new_test1.new_test1id]),
                    SetAttribute('subject', StringFormat([email.subject],
                                  ToString(LocalDate(), 'MMM-dd-yyyy') )), 
                    SetAttribute('description',StringFormat([email.description],
                                                            'Shannon', 'Mundy'  ))
                                                     )
                  ), 
                            
         SendEmail(GetVar('EmailID')) 
)

Note Syntax in the Email Templates

[new_test1.new_name.#] 

The hash symbol value will result in a blank string being inserted into the email template if there is no existing value in the record.

[new_test1.new_amount.0]
The zero at end acts as the default value if none is found on the record

[new_test1.modifiedon_fmt.#]
the _fmt will use the formatted value instead of the base value thereby inserting 'prettier' data into the 
email. 

Note Template Emails

You can pass in calculated or dynamic values created in the formula into the Template email using the {0}, {1} values etc. More static values that already exist in the CRM system can be passed into the global template email using the data slugs like [account.accountid] etc.

Reminder: When using {0} parameters for the subject or body of an email, you must include them in the StringFormat() function parameters unless you want them to fully overwrite anything in there previously
Example: Hello {0}, How are you?

SetAttribute('description', StringFormat([email.description], 'John') = "Hello John, How are you?"
SetAttribute('description', 'John') = "John"

Without the StringFormat([email.description], 'John') N52 will simply set the email description to John. Using the StringFormat([email.description], 'John') command tells N52 that you want to merge ‘John’ into the existing data in the email body at the first parameter position {0}.

Wizard - FindTemplateId

Please see below the wizard you can use to create the FindTemplateId() function call used in this formula. 

Note you will need to either type or paste in the following.