This example follows on from xRM Formula #111 and demonstrates how to solve the custom SharePoint folder structure requirement using a Decision Table instead of the Classic style formula.
The business requirement from the customer was that they did not want to use the standard Sharepoint folder structure. Instead, they are grouping their documents by geographical location.
Continent -> Country -> City
This is determined by 3 OptionSets on the Account record.
We will be using the same 4 xCache Records from the earlier formula:
- SharePoint_Site: Contains the URL to the SharePoint Site we are using
- SharePoint_SiteCollection: Contains the URL to the Collection we are working with on SharePoint
- SharePoint_Username: Username to access SharePoint
- SharePoint_Password: Access Password for SharePoint
North52 Decision Suite Solution - Decision Table
The North52 Decision Suite solution works like this,
- We create a formula of type 'Save - To Current Record' on the Document Location entity
- The formula will fire on Create of the Document Location only.
- It will create the necessary folders if they don't already exist
- It will delete the folder created on SharePoint automatically
- Then it updates the relative URL field on the Document Location to the new folder path
SharePoint Fields Filled Out
We use 2 actions in this Decision Table, the first one will create the folders using the value that is currently in the FolderPath Decision Table Calculation. The second is used to delete the folder automatically created by Microsoft out on SharePoint which automatically creates even before the creation of the Document Location entity in Dynamics 365.
SharePointCreateFolder( xCacheGetGlobal('SharePoint_Site'), xCacheGetGlobal('SharePoint_Username'), xCacheGetGlobal('SharePoint_Password'), true, xCacheGetGlobal('SharePoint_SiteCollection') + GetVar('FolderPath'), true )
SharePointDeleteFolder( xCacheGetGlobal('SharePoint_Site'), xCacheGetGlobal('SharePoint_Username'), xCacheGetGlobal('SharePoint_Password'), true, xCacheGetGlobal('SharePoint_SiteCollection') + [sharepointdocumentlocation.relativeurl] )
Wizard - xCacheGetGlobal
Did you know?
North52 TestShield allows rigorous regression testing of your Dynamics 365 system in-sprint
As well as being scheduled, or triggered from build pipelines, TestShield automated tests can be triggered manually for a quick mid-sprint regression test. This allows for quick testing of alternative ways to implement a requirement and measure the impact on existing processes.
It's quick to clone an existing test and try variations without affecting the original test set up too.