web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to auto generate a...
Power Apps
Unanswered

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

(0) ShareShare
ReportReport
Posted on by 66

Hi,


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


Thanks

I have the same question (0)
  • Christopher S Profile Picture
    on at

    Hi @jeffgreenrc 

     

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

     

    Best Regards,

  • jeffgreenrc Profile Picture
    66 on at

     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.

     

    Thanks

  • David Jennaway Profile Picture
    716 on at

    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

  • Billy Profile Picture
    396 on at

    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: https://i.imgur.com/Lvpak14.png 

     

    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.

    Advantages:

    • 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

    Disadvantages:

    • 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!

  • CU10100643-0 Profile Picture
    on at

    You can use the expression builder for this an use the null fuction for it. It's a simple solution but it works perfectly.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard