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.
North52 Decision Suite Solution
The North52 Decision Suite 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
North52 Decision Suite 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
Formula
SmartFlow(
SetVar('TemplateID', FindTemplateId('Survey Response Single Product Info', '1033')),
SetVar('EmailID', CreateEmailFromTemplate(GetVar('TemplateID'),
[msdyn_surveyresponse.msdyn_contact],
'contact',
SetAttributePartyList('from', 'systemuser', [msdyn_surveyresponse.owninguser]),
SetAttributePartyList('to', 'contact', [msdyn_surveyresponse.msdyn_contact]),
SetAttributeLookup('regardingobjectid', 'contact',
[msdyn_surveyresponse.msdyn_contact]),
SetAttribute('subject', 'North 52 Product Information',''),
SetAttribute('description',
StringFormat([email.description],
[msdyn_surveyresponse.msdyn_contact.firstname.?],
[msdyn_surveyresponse.owninguser.fullname.?])))),
ForEachRecord(
FindRecordsFD('FindSalesLitItemsName',
true,
SetParams(Case(CDecimalToInt32([msdyn_surveyresponse.msdyn_customnumber1]),
When(0), Then ('Bluetooth Pen'),
When(1), Then ('Keyboard'),
When(2), Then ('Surface Pro 3'),
When(3), Then ('Surface Pro 4'),
Default(Break())))),
CreateNote(CurrentRecord('title'),
'email',
GetVar('EmailID'),
'North52',
CurrentRecord('filename'),
Currentrecord('mimetype'),
CurrentRecord('documentbody'))),
SendEmail(GetVar('EmailID'))
)
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}" />
</filter>
</entity>
</fetch>
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.