Scenario Overview
In this scenario the requirement was to allow a user to create an email and attach Sales Literature PDF documents directly from a Dialog running on the Case entity.
It will display all available Sales Literature and then attach the relevant attachments depending on what the user decides.
North52 Decision Suite Solution
The North52 Decision Suite solution works like this:
- A formula of type 'Process Genie' is set up on the Email entity
- A second formula of type 'Process Genie' is then created on the Email entity
- A Dialog is created on the Case entity
- The dialog will display all available Sales Literature and ask the user to chose one to send to the customer
- The dialog will create the email to the customer and then call the N52 formula via the Process Genie
- This formula will retrieve the chosen Sales Literature Guid from the selected Sales Literature
- Then it will attach all Sales Literature Items to the newly created email
- Next we call another Process Genie step so we can add the Url of the newly created email into the dialog, this allows the user to open the email right from the dialog.
N52 Formula 1 Case - Send Sales Docs
N52 Formula 2 Dialog - Create Link
Dialog Setup
North52 Decision Suite Steps
The following set of steps outline how to create this Formula:
- Create the first formula of type Process Genie on the Email entity called Case - Send Sales Docs
- Create a FetchXML query on this formula and copy in the Fetch XML code from below
- Create a the second formula of type Process Genie on the Email entity called Dialog - Create Link
- Create an On-Demand Dialog on the Case entity as shown above
- Configure the Process Genie steps as shown in the below screen shots**
- Click save and test
** Please see the below notes on the Process Genies
Process Genie - Attach Documents
Process Genie - Generate Email Link
Formula Case - Send Sales Docs
ForEachRecord(
FindRecordsFD('FindSalesLitItems',true,
SetParams(GetParamFromUrl([email.choiceurl], 'id'))),
CreateNote(CurrentRecord('title'),
'email',
[email.activityid],
'North52',
CurrentRecord('filename'),
Currentrecord('mimetype'),
CurrentRecord('documentbody'))
)
Formula Dialog - Create Link
LinkDialogUrl('https://02042016.crm4.dynamics.com',
'email',
GetParamFromUrl([email.url], 'id'),
'Email for Customer')
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 1 : Putting the Dynamic Url of the newly created email into the Primary Entity ID field of the Process Genie is an example of 'context -switching'. This allows the formula to run on the email instead of against the original case.
Note 2 : The Formula Parameter Xml field allows us to pass additional data to the formula.
Syntax <entity><tag>information</tag></entity>
The entity has to match the entity type the Process Genie is working on, so if you are context switching in the Primary Entity ID field, then this entity should match it.
The tag is a name you give to the data so you can access it later
The formula can then access the data as if it is another attribute in the entity.
e.g. [email.url]