Tuesday, 17 September 2024

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

 

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


 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.


Also applied for normal file creation without guid. 

No comments:

Post a Comment

Power Apps Drag & Drop Kanban code sample

  Introduction: The Kanban Board App Developers at a software company use the Kanban board to show their progress on development tasks and b...