Incremental ID

0
Hi experts,   I want to create an incremental ID like ABC-001, ABC-002 … , where ABC is the prefix 001 is the incremental number each of the Id should be unique the Id should be generate when submitting a form How can I do this in Mendix?
asked
3 answers
0

Hi,

 

One of the possible ways to do it is using Microflow which will be executed before commit.

In Mendix Studio Pro, Add an event handler to the appropriate entity which runs before commit.

 

In the Microflow, retrieve the latest object from database by keeping the sorting order descending and range as first.

 

Then check if the object is not empty.

 

If object exists, process it’s SID by incrementing and set as SID of new object being created by form. If it doesn’t exists, set this to initial value, e.g. ABC-001.

 

Note: Do not set SID to AutoIncrement. Also, remove the SID field from Input form.

 

 

 

If you really need unique values prefer UUIDs with prefix such as ABC-{someUUIDhere}.

 

Regards

answered
1

Hi Renee,

 

The dynamic id can be created in the submit flow. fetch the first object in descending order, and make sure it is not empty. use substring to split the prefix, then add 1 while committing. If it is empty create the first ID

answered
0

thanks for the help!

answered