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?
Decision Tables Simplify Complex Logic
Decsion Tables allow you manage complex business logic without code. Key features include:
- Simple visualization in a compact table format
- Promotes grouping of rules in a single table
- Business logic can be controlled by domain experts
A Decision Table represents multiple related business rules by using conditions, actions and data values in a spreadsheet-style table. The Decision Table uses columns for the conditions and actions of the rules and rows to represent the associated data values.