How to remove GUID from folder name in Dynamics 365 CRM and SharePoint integration

By | November 6, 2020
 SharePoint Security Sync enables you to create custom document library structure in SharePoint and also 
customize the record folder name which is quite helpful for data storage and management in a smart way!

Introduction

Recently we had a requirement from a client, they wanted to remove the GUID appended to the folder name.

There is a hidden way to achieve this. It is stored in an OrganizationSettings, though they have not exposed a way on a UI to update this, however, this can be done programmatically.

Please follow this blog to understand the approach.

Default structure of SharePoint folder name (PrimaryFieldName_RecordGUID)

remove GUID from folder name in Dynamics CRM and SharePoint integration

To change the default behavior of the folder name we need to update CreateSPFoldersUsingNameandGuid property of organization to false.

Kindly follow the below steps to do that:

Below is the code snippet which I have tried from console application(c#) (if you want you can try with plugin/custom assembly as well) –

Entity orgEntity = new Entity("organization");

orgEntity.Id = new Guid(“46f31389-4d7d-43d7-b347-fae0d47f8b7f");

orgEntity["orgdborgsettings"] = "<OrgSettings><CreateSPFoldersUsingNameandGuid>false</CreateSPFoldersUsingNameandGuid></OrgSettings>”;

_crmhandler.UpdateRecord(orgEntity);

To get the organization ID, refer to below screenshot –

remove GUID from folder name in Dynamics CRM and SharePoint integration

Now when SharePoint folder will be created then it will contain only name not GUID.

remove GUID from folder name in Dynamics CRM and SharePoint integration

Conclusion

We can easily get rid of GUIDs in SharePoint folder name by changing Org setting.

2 thoughts on “How to remove GUID from folder name in Dynamics 365 CRM and SharePoint integration

  1. Derek

    Or just use the XRMToolbox tool or the solution made by a Microsoft PFE and available from github to install rather than having to write and execute code. This also only works if all record names (particularly account and contact) are completely unique, otherwise every record of the same name (e.g. John Smith” will all have the same share point document location.

    1. Inogic

      Hi Derek,

      Yes, you are correct. We can use XRMToolbox tool or the solution made by a Microsoft PFE. But this blog is for when you need to do this from Dynamics CRM (without adding external solutions).

      As well as this is right -every record should have a unique name otherwise files will upload to the same folder.

      Hope this clears the confusion.

Comments are closed.