SharePoint Folders and subfolders.

Recently I have been working on a project where there was a requirement to create a series of SharePoint folders in the older but still used Tree structure over a metadata storage.

Previously I have had to scope this up an pass it off to a Developer to build a custom plugin with workflow steps. All of which has a high on off cost to a the customer.

Here is where I used North52 to actually complete this task using their Business Process Activities solution. This tool removed the need for me get some custom C# or JavaScript development work completed. Where as a non-dev consultant I was then able to use the rich features of this solution to write out the steps I needed to create a folder structure with in SharePoint.

I have utilised the Smartflow and xCache  features of North52. The smartflow allows me to to group several bit of logic together and the xCache feature allows us to store credentials in the N52 entity “xCache” so when the formal is run it can retrieve the credentials for SharePoint for the org the formula is being run within.  These credentials are secured by Field Level Security.

You will notice on the left of the screen in the register tab we have some required fields. These are set as below to control how and what the formula interacts with

Formula Type : Save To Current Record

Mode : server side

Event : Create and Update

Source entity : Document Location

Source Property : All Properties

Target entity : Document Location

Target Property : Relative URL

The code above if triggered on the creation of a document location then runs through the steps :

Check fields contain data

If so set two variables. Room and Building

If these contain data then begin to create the SharePoint folder structure.

Here we are creating a parent folder ‘Building’ with sub folders ‘Room’ and ‘Subfolder1’

And finally before closing out the formula I am then setting the relative ULR of the document location to the ‘ParentPath’. This sets the default location when the user opens the documentation.

 

IfTrue(ContainsData([sharepointdocumentlocation.regardingobjectid]) and [sharepointdocumentlocation.regardingobjectidtype] = ‘bcg_room’,

SmartFlow(

SetVar(‘Room’, [sharepointdocumentlocation.regardingobjectid.bcg_Room.?]),

SetVar(‘Building’,[sharepointdocumentlocation.regardingobjectid.bcg_Buildingid.bcg_Name.?]),

 

If(ContainsData(GetVar(‘Room’),GetVar(‘Building’)),

SmartFlow(

SetVar(‘FolderPath’, GetVar(‘Building’)),

SharePointCreateFolder(

xCacheGetGlobal(‘SharePoint_Site’),

xCacheGetGlobal(‘SharePoint_UserName’),

xCacheGetGlobal(‘SharePoint_Password’),

true,

xCacheGetGlobal(‘SharePoint_SiteCollection’) +  GetVar(‘FolderPath’),

true),

SetVar(‘ParentPath’, GetVar(‘FolderPath’) + ‘/’ + GetVar(‘Room’)),

SharePointCreateFolder(

xCacheGetGlobal(‘SharePoint_Site’),

xCacheGetGlobal(‘SharePoint_UserName’),

xCacheGetGlobal(‘SharePoint_Password’),

true,

xCacheGetGlobal(‘SharePoint_SiteCollection’) + GetVar(‘ParentPath’),

true),

SetVar(‘FolderPath’, GetVar(‘ParentPath’) + ‘/’ + ‘SubFolder1’),

SharePointCreateFolder(

xCacheGetGlobal(‘SharePoint_Site’),

xCacheGetGlobal(‘SharePoint_Username’),

xCacheGetGlobal(‘SharePoint_Password’),

true,

xCacheGetGlobal(‘SharePoint_SiteCollection’) + GetVar(‘FolderPath’),

true),

),

SetVar(‘ParentPath’, [sharepointdocumentlocation.relativeurl])

),

SmartFlowReturn(GetVar(‘FolderPath’))

)

)

 

Author: beardedcrmguy

Share This Post On
Share via
Copy link
Powered by Social Snap