-2

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

Thanks!

Tim G
  • 147
  • 4
  • 11

1 Answers1

0

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.

jasonscript
  • 6,039
  • 3
  • 28
  • 43
  • 1
    Using new PowerApps solution customization experience, the Autonumber field can be created directly. On UCI field is editable so have to make it read-only in form editor. – Arun Vinoth-Precog Tech - MVP Oct 16 '19 at 02:15
  • Thanks! Will creating an autonumber show blanks for already created records, or will each of those records automatically have an autonumber once the field is created? – Tim G Oct 16 '19 at 04:28
  • If they are not automatically added to already created records, what is the best way to mass add them? – Tim G Oct 16 '19 at 04:29
  • @TimG They're not automatically added to existing records. I exported existing records and used excel to generate random characters. Not sure if this will work for you, depending on whether you have inactive records or not – jasonscript Oct 16 '19 at 05:17
  • Thanks! One more question: Is it possible an autonumber will ever create duplicates? I want to make sure they are always unique. – Tim G Oct 16 '19 at 14:58
  • @TimG I don't know. I looked in the article and it doesn't confirm that. It says that "The sequential segment is generated by SQL and hence uniqueness is guaranteed by SQL." and that "The random strings help you to avoid duplicates or collisions, especially when offline clients trying to create auto-numbers" so it looks like you should use a combination of the two – jasonscript Oct 17 '19 at 02:21