JaredA
Scholar

Automatically fill in a new unique ID

Hi all,

 

Currently working on a management of change tool where each request for change needs to have a unique id assigned to it.

 

I am using the new responsive designer to design this tool. How do i get nintex to automatically assign a unique ID to each new request? (E.G. when i click on "Request change" it automatically gives that request the number 00001)
The column is now a "Number" type in Sharepoint and already checks if that number is unique or not, but i want it to automatically fill in a unique ID instead of manually typing one in.

 

Any help is appreciated.

Thanks in advance,

Jared

 

Labels: (1)
0 Kudos
Reply
1 Reply
David-
Apprentice

Re: Automatically fill in a new unique ID

There are two ways you can do this. With a workflow or with a rule. In SharePoint there is a field by default which is always unique — the ID field. Even if you delete an item in the list, it will not reuse the same ID twice.

If you do this with a rule on the form, you would need to do something like:

  • Set the rule to run if the form is in edit mode (you cannot do this on new, because the ID will not be set since the form has not yet been submitted) AND the field where you want to store the value is blank.
  • Then set the value of the field using the formula "000000" + [Context].[Item ID]
  • Of course, you will need to do extra work if you always want it to be a certain number of characters long.

 

With a workflow, which is my preferred method since it does not require waiting for someone to edit the item for the field to be populated.

  • Set a workflow variable with the value of the list item ID and pad it with as many leading zeros as you would like the final length to be. I usually pad it with six zeros since that would take it to 999999 items in the list.
  • Then use the extract substring from end of string action to get your desired length.
  • Then use update list item action to set your field with the workflow variable.

 

I usually use this on the title field since that is the field to open items in SharePoint and it ensures that every one is unique.

David_0-1633114654375.png

Setting this to the title field also has a couple of extra benefits for me. Since the title field in SharePoint has to contain data, I set the default value to "Submitted" or something like that. I then make the field read only on my form. I train the process owners to look for items where they see "Submitted" in the title field, as that would be an indication where the workflow didn't run. Although, sometimes this happens because people immediately open the form in edit mode before the workflow has had time to set the value, and the lock on the record prevents the workflow from updating the field.

To overcome that problem, in the default view I set it to show items where title begins with zero. You will want to be sure that you index the title field in that case.

0 Kudos
Reply