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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Autogenerate next PO n...
Power Apps
Answered

Autogenerate next PO number

(0) ShareShare
ReportReport
Posted on by 287

I have a PO field in my dataverse database simply called PO.  I chose it as a text field so that I could theoretically modify it to fit my company's needs.  Currently my format is "YEARNumber"; Ex.. "2021403" for the year 2021 and the 403rd PO.


The next would logically be "2021404".

 

When I add a record, I'd like to have a function or way to Autopopulate "2021405".

 

I want the system to look through my database, figure out that the last PO was 2021404 and give me "2021405" as a text field.

 

Any ideas?

Categories:
I have the same question (0)
  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    hi @astrontelstar you can lookup the max valuie and add to it.

     

    consider the collection from the table being colSomething and the PO column called val. the wfirst part in the With statement get the maximum number an dthen adds one to it while the collect add it to your table.

    With(
     {
     _max: Max(
     colSomething,
     val
     ) + 1
     },
     Collect(
     colSomething,
     {val: Text(_max)}
     )
    )

     

    hope this helps

    R

     

     

  • astrontelstar Profile Picture
    287 on at

    When I run this - Max('Mprinted Business Operations',Value(PO)) I get "20200358" which is a PO from last year and not the most current which is 2020408.  My guess is it has something to do with delegation maybe?  Any more ideas?

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @astrontelstar 

    Max() is not delegatable.  Instead, use First(Sort(... , Descending) +1 to get the next number in the series.  First() isn't delegatable either but it doesn't matter because Sort() is.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 377 Most Valuable Professional

#2
11manish Profile Picture

11manish 165 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 110 Super User 2026 Season 2

Last 30 days Overall leaderboard