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 / Incremental numbers ba...
Power Automate
Unanswered

Incremental numbers based on Project Number

(0) ShareShare
ReportReport
Posted on by 407

Is there a way to automate a numbering system based on a project number?  For example, 

 

New Item New Project Number entered (12345) - CO Number = 12345-WC-01

New Item Same Project number (12345)  CO Number = 12345-WC-02

 

New Item New Project Number entered (8675309) - CO Number = 8675309-WC-01

New Item Same Project number (8675309)  CO Number = 8675309-WC-02

 

and so on

 

THANKS!

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @DCNehs 

     

    Yes it is possible. Filter the records by top 1 count by latest created date desc order. If you using SharePoint there is a column called created.Next get the CO Number of the latest record. Use split() expression using '-' to split, then use the last() expression to get the latest number whether its 01 or 02. Convert to integer using expression and increment the value.

     

    Thanks

  • DCNehs Profile Picture
    407 on at

    I'm still pretty new to expressions and such.    We are starting with when an item has been created/modified.  Would that cause issues? I'm guessing I have to use a Get Items to filter?

     

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @DCNehs 

     

    I did created a list similar like yours Project Number and CO Number. Here is the flow I built.

     

    image.png

    abm_0-1616028279661.png

    image.png

     

    image.png

     

    Above apply each loop have couple of expression. Here are the expressions I used.

     

    length(variables('LatestCONumber'))
    add(int(last(split(variables('LatestCONumber'),'-'))),1)
    int(outputs('Compose'))
     
    Below are the steps outside the loop
     
    image.png

     

    Above expression for formatting 1 to 01, 2 to 02, etc

     

    Here is expression I used.

     

    formatNumber(variables('NextSerialNumber'),'00')
     
    Here is my test results:
     
    image.png
     
    Note: If there are multiple records created at the same time the above logic won't work correctly. The Get Items filter may pick the wrong record which are waiting to update the CO Number. Your other option is schedule the flow to run outside the business hours then filter the records CO Number is null. The use the similar filtering technique (you don't need to use the Id for this scheduled scenario) to get the latest record and update the CO Number. 
     
    Hope it make sense. If you have any questions please let me know.
     
    Thanks
  • DCNehs Profile Picture
    407 on at

    THANKS!  I'm going to give this a try tomorrow.  

  • DCNehs Profile Picture
    407 on at

    Have tried this on 2 separate lists

    1 where its created/modified like the site I need to implement.  It's almost there but everything gets set to 01.  Maybe because of the created/modified item?

     

    just built a completely new test list and getting the following error for

     

    add(int(last(split(variables('LatestCONumber'),'-'))),1)

     

    Unable to process template language expressions in action 'Compose' inputs at line '1' and column '15181': 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    The error means its can't find the last expression index value. Check the run history and see what is the value of variable LatestCONumber?

     

    Thanks

  • DCNehs Profile Picture
    407 on at

     i've not been able to get to this yet.  Will be checking today...hopefully.

  • VIDIT Profile Picture
    666 on at

    Hi @DCNehs you can also achieve the same by using a plug-in if you want the numbering for the same to be synchronous 

    for example :- 

    you can create and 2 fields on your project entity -

    Suffix field named "SuffixField" which will contain your Suffix i.e. (WC)

    And an count field named (Count) which will increment and decrement depending upon the create or delete logic you will build 

     

    For Project 1
    Prefix field will be your CONumber on that project form which will contain your prefix i.e. (12345)

    so all together it will come out to be 12345-WC- 01

    For Project 2
    Prefix field will be your CO Number on that project form which will contain your prefix i.e. (8675309)

    so all together it will come out to be 8675309-WC- 02

    you can use the following link for reference and customize accordingly 

    you tube link - https://youtu.be/Mpgt8YCvU6g 

     

  • Verified answer
    DCNehs Profile Picture
    407 on at

    Still looking into this as I got busy with a project.  Will be going back and testing all ideas.  They have decided to continue entering the number manually for now, however i have a feeling that this will come in very handy for future projects.  

    THANKS ALL!!!

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 Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard