Get Next Number is used to generate a unique primary key for a new entity object record. Primary key prefixes are defined when the entity is created and get next number iterates a number starting at 10000000. The resulting generated primary key will look something like this: “ORH-10000000”. The next time GetNextNumber runs for that entity it will iterate to this: “ORH-10000001”.
The GetNextNumber service is needed when you want to insert into the SQL table that is associated with the entity, but do not want to use an Entity Create service. The Create service would auto assign an EntityId, but the SQL statement will not and already needs that number generated in order to insert the string.
GetNextNumber Use Case
In this example, we are looking at a webpart where you can enter a list name and select the ADD LIST button to create the list.
Below is the ADD LIST button process. First we check to see if a list with this name already exists. If the list does not exist, we then run the GetNextNumber service for the EC_List entity type. GetNextNumber will return a unique primary key for the EC_List entity type.
In our example, GetNextNumber returned a unique key for EC_List of LIST-10002808. We then run an insert into sql statement and use the GetNextNumber value to populate the ListId column in the EC_List table with the value of LIST-10002808.
Next time that the GetNextNumber service runs for the EC_List entity type. The value returned will iterate to the next number of LIST-10002809.
Here you can see that the only required input for GetNextNumber is the entity type of the entity you need a unique key for.
Below is the log data for this example. You can see here that GetNextNumber returned a unique key of LIST-10002808.
When the button process completes, you will see a confirmation message that the list was successfully created.
Finally, when you close the confirmation message, the List of lists will reload and you can view the new list you have created.