In this scenario, we will move the attachments from the notes on an account to that accounts SharePoint folder.
We are using Dynamics 365 Online and SharePoint Online for this example and have structured the formula to handle the standard out-of-the-box behavior from Microsoft.
To do this we will use a single North52 Formula with a Quick Button to trigger it.
N52 Formula Manager Solution - Decision Table
The Formula Manager solution works like this,
- We create a formula of type 'ClientSide - Calculation' on the Account entity
- When fired by the button the formula will get a list of all notes connected to that account.
- Any attachments it finds among the notes will be uploaded to that accounts SharePoint
As Microsoft by default attaches the guid (with the hyphens removed) to the SharePoint folder name, we do the same to specify the folder the file is being sent to.
To use this in your own instance of Dynamics 365 all you would need to do is update the SharePoint URLs from https://north52.sharepoint.com to your own SharePoint URL and update the username and password.
ForEachRecord( FindRecords('annotation', 'objectid', [account.accountid], '*','50','true'), iftrue(CurrentRecord('isdocument') = true, SetVar('FolderLocation', 'https://north52.sharepoint.com/sites/north52/account/' + [account.name] + '_' + Replace(ToString([account.accountid]), '-', '')), SharePointCreateFile('https://north52.sharepoint.com/sites/north52', ' firstname.lastname@example.org', 'Password', true, true, GetVar('FolderLocation'), CurrentRecord('filename'), CurrentRecord('documentbody') ), UpdateRecord('annotation', CurrentRecord('annotationid'), SetAttribute('notetext', '123'), SetAttribute('documentbody', '?'), SetAttribute('filename', '?'), SetAttribute('filesize', '?'), SetAttribute('isdocument', 'false'), SetAttribute('notetext', CurrentRecord('notetext') + '\r\n\r\n'+ GetVar('FolderLocation') +'/'+ CurrentRecord('filename')) ) ) )
To configure Dynamics 365 to communicate with SharePoint you must carry out the following steps:
Navigate to Settings -> Document Management.
Select Enable Server-Based SharePoint Integration.
Click Next - then select Online for the Integration
Enter the URL for the SharePoint site.
Click Next and then Enable.
Hit Finish and this step is complete.
Next select Document Management Settings
Enter the URL for the SharePoint instance again and click Next
Use the screen below to configure the Document Management Settings.
Hit Next and then Finish and the Integration between SharePoint and Dynamics 365 is now configured.
The file transferred to SharePoint.
To add a Quick Button to the Account entity in Dynamics 365 - please see our detailed guide here.