Views:

Scenario Overview

This scenario is an enhancement of the Survey Response 1 article on sending Sales Literature. Again 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 any and all 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 containing pdf documents for all the selected products.

Voice of the Customer Survey 

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 will query each of the Answer entities where they match the Question name.
  • For each answer it finds, it retrieves 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

Customer 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 FetchXML query called GetSurveyResponseAnswers 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('QuestionName', 'Select any products you would like to learn more about'),
  
       SetVar('TemplateID', FindTemplateId('Survey Response Multiple 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',
                              'msdyn_surveyresponse',
                             [msdyn_surveyresponse.msdyn_surveyresponseid]),
                  SetAttribute('subject', 'North 52 Product Information'), 
            SetAttribute('description', StringFormat([email.description],
                         [msdyn_surveyresponse.msdyn_contact.firstname.?],
                         [msdyn_surveyresponse.owninguser.fullname.?])))),
    
  ForEachRecord(
        
      FindRecordsFD('GetSurveyResponseAnswers',
                     true, 
                    SetParams([msdyn_surveyresponse.msdyn_surveyresponseid],
                                        GetVar('QuestionName'))), 
    
        ForEachRecord(

                    FindRecordsFD('FindSalesLitItemsName',
                                  true, 
                                 SetParams(CurrentRecord('msdyn_name'))),

                    CreateNote(CurrentRecord('title'), 
                                'email', 
                                GetVar('EmailID'),
                                'North52',
                                CurrentRecord('filename'),
                                Currentrecord('mimetype'),
                                CurrentRecord('documentbody')))),

  SendEmail(GetVar('EmailID'))
)     

Fetch XML FindSalesLitItemsName

<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>

Fetch XML GetSurveyResponseAnswers

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
  <entity name="msdyn_answer" >
    <attribute name="msdyn_name" />
    <attribute name="msdyn_answerindex" />
    <attribute name="msdyn_questionid" />
    <link-entity name="msdyn_questionresponse" from="msdyn_answerid"
       to="msdyn_answerid" link-type="inner" >
      <filter>
        <condition attribute="msdyn_surveyresponseid" operator="eq" value="{0}" />
      </filter>
      <link-entity name="msdyn_question" from="msdyn_questionid" to="msdyn_questionid" >
        <filter>
          <condition attribute="msdyn_name" operator="eq" value="{1}" />
        </filter>
      </link-entity>
    </link-entity>
  </entity>
</fetch> 

Note 1 : 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 either type or paste in the following. 
 

Did you know?

North52 TestShield benefits Dynamics 365 apps testing

Benefits of using North52 TestShield's automated testing framework for Dynamics 365 apps:

1. Accelerate Automated Testing
  • Enables continuous testing of Dynamics 365 apps with speed and agility
  • No-code test designer enables non-developers to build tests
2. Improves Test Coverage
  • Better ROI by a reduction in UAT defects and production defects
  • Defect prevention at early stages of the project life cycle
3. Fix Defects Faster
  • Get fast feedback on the impact of process changes
  • Repeatable automated test execution simplifies problem solving
  • Quickly resolves failing conditions from complex end-to-end tests
4. Faster Delivery and Higher Quality
  • Broader test coverage and fewer defects released to production
  • Reduced risk and faster release cycles through earlier and automated testing
  • Lower costs related to complex test environment management
  • Reduces time to market by validating builds faster
5. Increased Testing Productivity
  • Assist in the generation of automated test scripts that are repeatable and extensible
  • Detailed analysis of test trace logs enable easy detection of errors to be fixed
  • Automation can perform regression tests which ensures system stability while enhancing the application continuously
  • No manual operation increases efficiency and quality of testing

Learn more about TestShield