Overview
Microsoft Dynamics Marketing allows for the collection of data from form submissions. However, each data field submitted is stored in a separate Dataverse record (using JSON for lookup values) which makes it difficult to use this data in business processes.
Using North52's Decision Suite business rule engine we'll show how you can reduce complexity and easily create a record in Dynamics 365 from the data submitted via Dynamics Marketing Form.
In this example, a landing page with a Dynamics Marketing Form has been configured to allow people to submit referrals.
North52 Decision Suite Solution
The North52 Decision Suite solution works like this:
- A Formula is set up to run on the update of a Marketing Form Submission
- The Formula ensures the Form Submission is at a status of Success
- It then retrieves an entity collection of the Marketing Form Field Submissions and loads them into an xCache table in memory
- The Referral record is created mapping the values found in the Marketing Form Field Submissions into the fields on the Referral record
Marketing Form
The Dynamics Marketing form is set up with multiple fields including Lookup (Referral Type) and Choice (Preferred Reward) type fields:
Marketing Form Submission
After a user submits the form the following Marketing From Submission record is created along with associated records for each field on the form. You can see that the Referral Type field value is stored as JSON. North52 provides functions to easily parse JSON data:
Referral Record Created in Dynamics 365
Once the Marketing Form Submission record has the status automatically set to Success, the North52 business rules engine Formula executes and creates a new Referral record, mapping the field values to the appropriate fields on the Referral record, including setting the lookup and choice fields:
Set up Formula
- Create a new Formula, setting the following values in the Formula Guide:
- Source Entity set to Marketing Form Submission
- Set Formula Type to Save - Perform Action
- Select the Decision Table editor
- Change the Name of the formula to Marketing form submission - Create Referral Record
- Click Save
- Right-click on the Decision Table and select Set Sheet Options -> Use CreateRecord
- In the Condition column, select the Source tab on the left side of the formula editor, and then cell A2 and click on Status Reason
- Select cell A4 and then expand the Status Reason node and click on Success
- Add Action columns for each of the fields in the Referral Record
- Search for the Referral entity in the Explore tab on the left side of the formula editor
- In row 2, for each column, click on the field name that you want to populate
- In Row 4, for each field you are populating, put either
- {MapLookupValue[[fieldname]]}
- {MapBasicValue[[fieldname]])
Note: The fieldname is the Marketing Field Submission field name:
FetchXML
The FetchXML query used to retrieve the Marketing Field Submissions connected to the Marketing Form Submission is defined on the Global FetchXml tab:
Global Calculations
There are two Global Calculations defined to execute the FetchXML and load the results into the xCache in-memory data table:
FindMarketingFieldSubmissions
FindRecordsFD('FindMarketingFieldSubmissions', 'true', SetParams([msdyncrm_marketingformsubmission.msdyncrm_marketingformsubmissionid]) )
xFieldSubmissionsLocal
xCacheLoadLocalEx('xFieldSubmissionsLocal', GetVar('FindMarketingFieldSubmissions'))
Global Actions
There are two Global Actions defined that are used in the Decision Table to extract and set field values:
MapBasicValue
xCacheGetLocal('xFieldSubmissionsLocal', 'msdyncrm_fieldvalue', '?', '0', 'msdyncrm_fieldname = "{0}"')
MapLookupValue
GetVarJsonValue('Id', '?', xCacheGetLocal('xFieldSubmissionsLocal', 'msdyncrm_fieldvalue', '?', '0', 'msdyncrm_fieldname = "{0}"'))