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 Automate / Auto generate ID up to...
Power Automate
Answered

Auto generate ID up to a maximum number

(0) ShareShare
ReportReport
Posted on by 4

Hello,

 

I am attempting to build a form/list in which when a new response is submitted the list generates a reference number. However I am wondering if there is a way to keep this number to a maximum of 2 digits, so that when it gets to 99 it the next row will become 1 again. 

TIA

Categories:
I have the same question (0)
  • wskinnermctc Profile Picture
    6,519 Moderator on at

    Can you use the ID number of the list item? This will obviously get larger than two digits if you have more than 99 items. However, it will always be unique and not repeated.

     

    I guess if you absolutely must have only two digits, you could still use the List Item Id number but only take the last two digits.

     

    Do you think that would work for you?

  • DCW1992 Profile Picture
    4 on at

    @wskinnermctc Thank you for your very quick reply. The second option would be best, repetition of ID’s is not an issue and 2 digits is a must due to another systems limitation.


    How would I ensure only the last two digits of the list ID showed - a calculated column?

  • ScottShearer Profile Picture
    25,278 Most Valuable Professional on at

    @DCW1992 

    You could approach this in a number of different ways.  Probably the easiest way is to have a separate list with a single row of data - let's call this the Reference list.  Any time a new item is created in the primary list, grab the single row of data from the Reference list.  The value of the number and use it.  Then, update the number stored in the reference list.  If the current number is 99, update it to 1.  Otherwise add 1 and save to the Reference list.  This is not a great solution if the list will be updated frequently.

    Let me know if you need help implementing this solution and let me know where your data is stored.

    Another way is to retrieve the last item saved to your list.  Add 1 to the number value or use 1 if the value last used was 99.

    Once again, let me know if you need help.

     

     

  • Verified answer
    wskinnermctc Profile Picture
    6,519 Moderator on at

    Add a List column of single line text type.

     

    After you initially Create Item in the list, add an Update Item action afterwards. Then put the Id in an expression function that will get the last two digits out of the ID.

     

    This expression below will result in the last two digits as in '00', '01', '02',...'54','55','56',.....'98', '99', '00', '01, etc,

    substring(string(formatNumber(outputs('Create_item')?['body/ID'],'000')),sub(length(string(formatNumber(outputs('Create_item')?['body/ID'],'000'))),int(2)))

    Here is a quick example in a flow:

    Create the Items - Format the ID of new item - Then Update the itemCreate the Items - Format the ID of new item - Then Update the item

     

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…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 378 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 273 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 135 Most Valuable Professional

Last 30 days Overall leaderboard