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
2. Next, create two workflows to perform the function of sub-folder creation. I’ve named them as follows:
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:
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:
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
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:
- CRM 2011 and SharePoint 2010: Configuration and Folder Structure
- Bulk Creation of SharePoint Folders and Automated Integration with Dynamics CRM
- Displaying an Office 365 SharePoint iFrame in CRM