Scenario Overview

This scenario is a continuation of the articles on sending Sales Literature. This time we are integrating with the Voice of the Customer solution.

The business requirement is that we send out product information to a customer who has filled in a survey. 
For this example a customer can choose one of the following:

  • Bluetooth Pen
  • Keyboard
  • Surface Pro 3
  • Surface Pro 4

When the Survey Response is received from the customer we will automatically process the response and send an email out to the customer with some PDF documents attached.

Voice of the Customer Survey 

We set up a question on our survey with a list of products as a Single response option set and set the response mapping to Custom Number 1.

N52 Formula Manager Solution

The Formula Manager solution works like this:

  • A formula of type 'Process Genie' set up on the Survey Response entity  
  • A workflow is set up on the Survey Response entity, to be triggered on the creation of the survey response.
  • This workflow will invoke the N52 formula via a Process Genie step.
  • The Formula creates the email to be sent out to the customer.
  • Then it reads the value stored in Custom Number 1 of the survey response.
  • It uses a Case statement to match the number value back to the correct product name.
  • Next it finds the correct Sales Literature based on the name
  • Then it will attach all Sales Literature Items to the newly created email
  • Finally it will send the email out to the customer

N52 Formula

Workflow Setup

Template Email

N52 Formula Manager Steps

The following set of steps outline how to create this Formula:

  • Create the formula of type Process Genie on the Survey Response entity 
  • Copy in the formula below
  • Create a FetchXML query called FindSalesLitItemsName on this formula and copy in the Fetch XML code from below  
  • Create a workflow on the Survey Response entity as shown above
  • Insert the formula short code into the Process Genie step
  • Click save and test


      SetVar('TemplateID', FindTemplateId('Survey Response Single Product Info', '1033')),

      SetVar('EmailID', CreateEmailFromTemplate(GetVar('TemplateID'),
                    SetAttributePartyList('from', 'systemuser', [msdyn_surveyresponse.owninguser]), 
                SetAttributePartyList('to', 'contact', [msdyn_surveyresponse.msdyn_contact]),
                    SetAttributeLookup('regardingobjectid', 'contact',
                    SetAttribute('subject', 'North 52 Product Information',''), 

                                                        When(0), Then ('Bluetooth Pen'),
                                                        When(1), Then ('Keyboard'),
                                                        When(2), Then ('Surface Pro 3'),
                                                        When(3), Then ('Surface Pro 4'),                                 


Fetch XML

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
  <entity name="salesliteratureitem" >
    <attribute name="filename" />
    <attribute name="filetypecode" />
    <attribute name="mimetype" />
    <attribute name="documentbody" />
    <attribute name="modifiedon" />
    <attribute name="title" />
    <attribute name="salesliteratureitemid" />
    <order attribute="title" descending="false" />
    <filter type="and" >
      <condition attribute="salesliteratureid" operator="eq" uiname="Surface" 
       uitype="salesliterature" value="{0}" />

Note Template Emails

You can pass additional information into the template by using the {0}, {1} parameters into template.

In this example, the subject line the Template is {0}. 
When this line of code executes into the Formula:
SetAttribute('subject', 'North 52 Product Information'),   

The {0} in the subject line will be replaced with the 'Bluetooth Pen - Product Information'

[email.subject] and [email.description]
If you want to replace multiple {0}, {1}, {2} values within the body or a subject bar of an email then you should use the StringFormat([email.description], 'value to be used') command.

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 type or copy in both lines here. 

Did you know?

You can easily copy/clone test data in TestShield

Once you have set up test data with TestShield it is easy to create a copy/clone and make changes. It is centrally stored so that all users creating tests can use the test data in their tests. This approach dramatically reduces the time it takes to create tests, enabling teams to deliver Dynamics 365 projects faster and at less cost.

Learn more about TestShield