Views:

Scenario Overview

In this scenario, 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.

xCache Records

For this solution, we will be using 4 xCache Records:

  • 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 

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 and only if the Regarding is populated by an Account
  • 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

                       

N52 Formula Manager Steps 

The following set of steps will set this formula up for you.

  • Create a new formula of type 'Save - To Current Record'
  • Set the Source Entity to 'Document Location '
  • The Event is 'Create only'
  • Set the Target Property to 'Relative URL '
  • Create the xCache Records for the Site URL, Username, Password & the Collection you are using
  • Copy and paste the formula below into the formula canvas
  • Save the formula
  • Click Save and you are ready to test

Formula : Classic

IfTrue(ContainsData([sharepointdocumentlocation.regardingobjectid]) and 
  [sharepointdocumentlocation.regardingobjectidtype] = 'account',

  SmartFlow(

    SetVar('Continent', [sharepointdocumentlocation.regardingobjectid.new_continent_fmt.?]),                                                        
    SetVar('Country', [sharepointdocumentlocation.regardingobjectid.new_country_fmt.?]),
    SetVar('City', [sharepointdocumentlocation.regardingobjectid.new_city_fmt.?]),

    If(ContainsData(GetVar('Continent'),GetVar('County'),GetVar('City')),
      SmartFlow(
        SetVar('FolderPath', GetVar('Continent')),
        SharePointCreateFolder(
          xCacheGetGlobal('SharePoint_Site'), 
          xCacheGetGlobal('SharePoint_Username'), 
          xCacheGetGlobal('SharePoint_Password'),
          true,
          xCacheGetGlobal('SharePoint_SiteCollection') + GetVar('FolderPath'),
          true),

        SetVar('FolderPath', GetVar('FolderPath') + '/' + GetVar('Country')),
        SharePointCreateFolder(
          xCacheGetGlobal('SharePoint_Site'), 
          xCacheGetGlobal('SharePoint_Username'), 
          xCacheGetGlobal('SharePoint_Password'),
          true,
          xCacheGetGlobal('SharePoint_SiteCollection') + GetVar('FolderPath'),
          true),

        SetVar('FolderPath', GetVar('FolderPath') + '/' + GetVar('City')),
        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])
      ),
      SetVar('FolderPath', [sharepointdocumentlocation.relativeurl])
    ),
    SmartFlowReturn(GetVar('FolderPath'))
  )
)

The Document Location on the Account


  

SharePoint Folder

Wizard - xCacheGetGlobal

Please see below the wizard you can use to create the xCacheGetGlobal() function call used in this formula. 

Note you will need to create the xCache beforehand. 
 

Did you know?

North52 helps Insurance Providers manage complex rules in their Dynamics 365 systems

The North52 Decision Suite helps insurance professionals manage the thousands of rules that form insurance approval, rate and commission calculations. Our easy to use, point and click interface allows for quick updating of rules by knowledgeable insurance analysts without programming experience. We assist in processes such as:

  • Task checklists
  • Quote calculations
  • Product configuration
  • Pricing
  • Commissions
  • Claims handling

Learn more about the North52 Decision Suite