Today we’ll describe a time-saving trick that automatically creates SharePoint sub-folders to be used in the integration with Microsoft Dynamics CRM.


When configured to do so, Microsoft Dynamics CRM 2011 offers an integration with SharePoint that will create a folder for each record in CRM. Once the corresponding SharePoint folder is created, you can add documents as well as create new folders. If you need the same sub-folders created for each folder, they can be automatically created, rather than having to do it manually.

This automatic creation could be performed by a SharePoint plugin, but SharePoint workflows can also accomplish this task without coding. To do this, you will need SharePoint Designer 2010, and it can be downloaded from Microsoft downloads.

1. First, create two new columns in the SharePoint Account library:

  • ParentFolder – Text field to populate with the parent folder name
  • SubFolders – Choice field for status values

SharePoint sub-folders - Account Library

2. Next, create two workflows to perform the function of sub-folder creation. I’ve named them as follows:

  • NewAccount_SetStatus
  • NewAccountFolder_Created

3. Open SharePoint 2010 Designer and connect to your SharePoint site where CRM integration creates folders.

4. Select ‘Workflows.’ We will need to create two List Workflows for the Account library:

a. NewAccount_SetStatus

This fires upon creation and is initiated by a user in CRM when the Documents link is clicked for the first time and they accept the prompt to create a new folder.

Step 1 checks to see if the newly created item is a Folder – if not, the workflow stops:

If it is a folder, it checks to see it is one of the two folders:

  • Sales
  • Technical

If it is, it stops the workflow. (We do not want the workflow to create another set below each sub-folder.)

Lastly, the workflow sets a column status field ‘SubFolders’ to ‘Pending’:

This fires the second workflow, which reacts to Changes

b. NewAccountFolder_Created

Step 1 of this workflow checks the ‘SubFolders’ value.

If ‘Pending’ – this means the newly created folder is a CRM folder, therefore it needs to create the two sub-folders:

The two folders are created and the parent’s SubFolders value is set to ‘Created’. This indicates that the parent folder has had its children created and will not recreate them if the parent folder is changed:

For the Create Item, use the Folder name to dictate the path, hard-coding the ‘/Sales’.

Repeat with another Create for the second sub-folder: Technical.

5. Save and Publish the workflows:

Now from a CRM Account record, upon creation of the Account folder, the workflows should fire and create the sub-folders.


For other CRM and SharePoint articles, check these out:

Happy CRM’ing!

Avatar for Joe D365

Joe D365

Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.