In this scenario the business requirement was to automatically attach documents, from a SharePoint Site related to an Opportunity, to an email and send that email to a customer.
For this example we are using Dynamics 365 with SharePoint Online. We are also assuming that all files in the SharePoint folder should be sent to the customer although we could filter them in the formula if we needed to.
North52 Decision Suite Solution
The North52 Decision Suite solution works like this,
- A Formula of type 'Process Genie' is created on the Opportunity entity
- xCache records are created to store the SharePoint Username, Password and the SharePoint URL
- A workflow is set up on the Opportunity to create the email to the customer
- A North52 Process Genie step is added to the workflow
- The Formula searches the SharePoint site for documents connected to the Opportunity
- Next it adds each document as an attachment to the email
- Finally the formula sends the email
*Note: Although the Workflow executes on the Opportunity entity, the formula executes on the Email entity. This is achieved by 'Context-switching' within the North52 Process Genie.
North52 Decision Suite Steps
The following set of steps outline how to create this Formula
- Create the xCache records to store the SharePoint Username, Password and URL
- Create a new Formula of type 'Process Genie'
- Copy and paste the code below into the formula
- Create the Workflow and configure it as shown below
- Click Save & Test!
Note: Context-Switching is achieved here by passing the Record URL of the newly created email as the Primary Entity ID for the Process Genie to execute on.
SmartFlow( ForEachRecord( SharePointFindDocumentsByFetchXml('opportunity',[email.regardingobjectid]), CreateNote(currentrecord('fullname'), 'email', [email.activityid] , 'Notes', CurrentRecord('fullname'), CurrentRecord('filetype'), SharePointGetFile( xCacheGetGlobal('SharePoint_Demo_URL'), xCacheGetGlobal('SharePoint_Demo_Username'), xCacheGetGlobal('SharePoint_Demo_Password'), true, CurrentRecord('absoluteurl') ) ) ), SendEmail([email.activityid]) )
List of fields returned by SharePointFindDocumentsByFetchXml
Wizard - xCacheGetGlobal
Did you know?
North52 helps with Approvals and Routing in Dynamics 365
Every organization is different and thus has different approval and routing requirements.
When there is complexity involved in your requirements, North52's Decision Tables can help simplify that complexity. Our no-code editor helps you build your approval/routing rules easily.