How to do auto number calculation Through microflow

I want a auto number calculation through microflow
4 answers



Create one integer attribute in your entity, You have to call a microflow when you create an object. In the microflow, you should retrieve the last object of your entity by using the Retrieve activity.

You can get your entity's last object by making a range First and sorting an integer in descending order. Now you can achieve this by adding one to the previous int attribute which you retrieve.  


If you want to an automatically incrementing number in your entity you just need to create an attribute of type autonumber. There is no need for a microflow to do this.


Hi Pavani,

If you prefer to run your auto-number over microflow in stead of Mendix predefined auto-incement on an attribute, all you have to do is;


  1. retrieve from the entity
  2. run a count aggregate function (mendix will bind these togehter as one query)
  3. The count output + 1 is your new auto-incremented number.

once more; its better to use the auto-increment on your attribute.


Good luck,



The suggestions on how to create an autonumber through microflow are only valid as long as you can rule out that two users are running the microflow at the same time, which might lead to creation of the same number twice.

More precisely “at the same time” means that the second user starts the microflow before the first user has committed his new “auto”-number to the database. In this case both users will pull the same old highest number / same entity count and thus will create the same count+1 value.

There is no easy solution to this.

If you can’t directly use type autonumber, e.g. because you need to add a prefix, it might be better to use the autonumber type anyway & derive your prefixed autonumber from that. The microflow for this would look like this:

  1. Create new object (generating new autonumber)
  2. Commit new object (prerequisite to work with the autonumber attribute)
  3. Calculate new attribute “PrefixAutonumber” as <prefix> + <autonumber attribute>
  4. Do whatever else needs to be done
  5. Commit object again