Search code examples
dynamics-crmdynamics-crm-online

How to create GUID field in Dynamics CRM?


I wanted to create a new GUID field for an entity in the Dynamics CRM online. But surprisingly there is no data type for it.

Why is that? And what is the best option if I want to create a "reference" field to an external system? If it is "Single line of text" what is the best approach to ensure that entered values are proper GUIDs (from API point of view).


Solution

  • If you want to ensure that the value entered inside a single line of text field is a GUID, you need to create a synchronous plugin on the create and update event of the field and throw an exception if the value is not a GUID.

    You can do also this with a Workflow and a Custom Activity.

    In addition to this plugin/workflow you can write a JavaScript attached to the OnChange event of the field that enforce the check when the field is updated by CRM Web UI.