How to remove GUID from folder name in Dynamics 365 CRM and SharePoint integration
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)
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 –
Now when SharePoint folder will be created then it will contain only name not GUID.
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