Search code examples
javascriptdynamics-crmmicrosoft-dynamics

In Dynamics CRM, how can I create a field that is a 6-character randomly generated unique GUID?


How can I create a custom field that is a 6-digit (or 6 character) randomly generated unique GUID in CRM?

Thanks!


Solution

  • You can use the autonumber feature

    https://learn.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/create-auto-number-attributes

    From the link

    When you add the auto-number attribute as a field to a form, the auto-number attribute field behaves as read-only in the form, and end-users cannot edit the field. The value is set only after you save the entity. You can see auto-number attribute as any other field value in views, grids and so on

    You'll need to use the XrmToolbox to configure the autonumber. You can create a 6-character random string with {RANDSTRING:6}


    Update on uniqueness

    The random strings help you to avoid duplicates or collisions, especially when offline clients trying to create auto-numbers

    and

    The sequential segment is generated by SQL and hence uniqueness is guaranteed by SQL.