AutoNumber attribute

I have an attribute being an AutoNumber, starting by 1. Then I have a Pop-Up Layout which creates this particular object, the autonumber attribute starts by 1, but when I click cancel the AutoNumber keeps counting. How can I prevent this, so when cancelling the AutoNumber wont count? Thanks in advance.
4 answers

You could try creating a non-persistent copy of your entity in the model (without the Autonumber attribute) and use this to enter details for the new record.

Then with a custom save button push the data from the non-persitent record to a new record in the persistent entity. That way you will only increment the autonumber when you save the new record.


Here is a rough list of the steps to take to do this:

  1. To create a non-persistent copy of your entity, open the Module Domain Model and select your main entity (lets say it is Customer). Copy it (Ctrl-C) and paste it somewhere else on the canvas (Ctrl-V). It will create a copy called Customer_2. Double-click on the new Customer_2 entity and change the Persistable property to No.

  2. Delete the autonumber attribute from the new Customer_2 entity. Add any associations from Customer_2 to other entities that exist for your main Customer entity that are going to be needed to create a new record (such as an association to State and Country for the address, perhaps)

  3. Create a data view form for the entity Customer_2 to be used when creating a new Customer. On the form, delete the standard Save button if present, and replace it with a Microflow action button named Save. The microflow should take the Customer_2 entity as a parameter, and have actions to create a new Customer object, set all its attributes to the values from the Customer_2 object, commit it then Close the current form.

  4. In your data grid form displaying the list of Customer records, delete the standard New button and replace it with a Microflow action button with settings to pass nothing to it. This microflow should create a new object in the Customer_2 entity, then show this entity in the data view form created in step 3



You can create an Entity to store the AutoNumber ID, creating the Object of that Entity and committing only when saving.

That way when you enter the page and exit anyway, it won't add a number to the ID.


You can't....Autonumbers calculation is not exposed through modeler, api, etc. If you want to have a different behavior, you'll need to code up your own 'Autonumber' functions.


I have implemented this in an app that is a multitenant app. In the included model share, you will see the microflow only proceeds for an employee (user type for each tenant), and then gets the next unique id for that client (clients are the tenants). Please note that this model requires an entity called UniqueID, which has one attribute called UID and one association to the Client entity. Locking is included in this microflow in order to ensure uniqueness.

Model Share Here

Hope that helps.