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
N52 Formula Manager Solution - Decision Table
The Formula Manager 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 Quick Buttons can be used on Dynamics Portals Entity Forms
That's right, you can trigger complex business rules via a button on an Entity Form. You could:
- Retrieve information from another entity or even another system and return it to the form
- Create or Update records on the button click
- Process advanced decision logic from information that has been completed on the form but not submitted
- Have dynamic buttons showing different options dependent on your business rules
- And much more!
Learn more about North52 Quick Buttons for Dynamics Portals