Showing results for 
Search instead for 
Did you mean: 
Helper III
Helper III

How to auto generate auto number field in power automate or flow


I want to know how can I by default let Power apps auto generate the auto number field in power automate or flow.


Community Support
Community Support

Hi @jeffgreenrc 


Can you please be more specific about "generate the auto number field in power automate or flow"?


Best Regards,

If this post helps you give a :thumbs_up: and if it solved your issue consider Accept it as the solution

 i have a auto number field in entity which is basically a primary key. In model driven app, this number is incrementing by itself. Is there a way we can have the same functionality in power automate or flow.



I don't think you'll be able to do this in a robust way (i.e. being certain to avoid duplicates) using Power Automate. Any robust autonumber mechanism needs to be able to lock a shared resource (i.e. the current / next number) to ensure numbers are generated sequentially (rather than concurrently). The design of Power Automate doesn't give you any locking control; you'll need to use something backed by a data store - e.g. CDS autonumber fields, or a SQL table with an identity column

Helper V
Helper V

Hi there,

So I have been trying to the same thing and so far I managed to get an autonumbering system in power automate without the issue of having duplicates. You will need 2 fields in order to have a completely unique numbering system, 1 field where your autonumbering code will be saved and 1 field to determine the index.
It is true that you will need limit your trigger of your flow to a degree of parallelism of 1. This way the flow will execute 1 at the time generating your codes in a unique fashion.

To generate autonumbering code based years you will need quite a few steps to go through (I added a screenshot of it aswell at the bottom of the steps):

  1. Create your code filter variable as a string (i used concat with 3 separate compose steps to create each part of the string separately):
    e.g. for deliveries: D2021-
  2. Create an index variable as an interger that holds the numbering for that specific year initialize with 0.
  3. List your records of your entity (in my example deliveries)
    You can filter your list by checking if the code starts with your code filter from step1
    Then order by the indexcode field which will contain only the digits that come after your filter as a whole number field. Also limit your result by 1 record only to get the last record (in case you change your codes manually for some reason you can still get the last record that follows this base sequence).
  4. Then check for the length of that list if there is 1 then get the index code using first() then set that value as your index of that year, if no item was found in case no records for that specific year exist then set the index to 0.
  5. Then I increment the value with 1
  6. and use a compose to concat the filter with the index.

As you can see in this screenshot: 


When you create the record don't forget to set both the code and the index of the code. Otherwise this method won't work properly.


You can easily alter this setup for other values you want to include like option sets and stuff.


  • You can still change the codes as you want
  • You can easily create gaps in your codes by changing the index with one value higher


  • If you changed the value you can only revert the value manually. (unless you make a separate flow to revert the value)
  •  Flow has to be set to a parallel degree of 1 otherwise it is possible to have multiple records with the same code.

Kind regards,


Billy Cottrell


If this post helped you click the like button and if it solved your issue please accept it as the solution!

Helpful resources

October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022


Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (4,240)