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 / Auto genarate invoice ...
Power Apps
Answered

Auto genarate invoice number

(0) ShareShare
ReportReport
Posted on by 521

Hello,

Is there a way i can generate invoice number when clicked create new record using a form from Sharepoint Data Source?
here a is what i need an example format

Capture11.JPG
Thanks 

Categories:
  • Verified answer
    365-Assist Profile Picture
    2,327 Moderator on at

    The easiest way to is to use the ID Column in SharePoint. It will autoincrement for every record.

    365Assist_0-1656635261351.png

     

    However, If you prefer to control a number in Power Apps you can do it this way.

    1 - Create a Number Column in SharePoint.

    365Assist_1-1656635327803.png

    2 - In Power Apps Create a Collection (App -> OnStart). You may need to do this as you could hit Delegation warnings if you use the column in SP directly.

    365Assist_2-1656635412524.png

    ClearCollect(colInvoiceNumber,'Demo List'.'Invoice Number')

     

    3 - Get the last Invoice Number an add 1.

    365Assist_3-1656635548898.png

    Sum(Max(colInvoiceNumber,'Invoice Number')+1)

    ---------------------------------------------------
    Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful as can help others.

    Subscribe: https://www.youtube.com/channel/UCFpvUlpx84FuIPOdInGKMTw
    Twitter: https://twitter.com/assist_365

    Regards
    Darren Lutchner - 365 Assist

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

    @PowerApps11 

    Much better is First(Sort,ID,Descending)).ID+1

    The other methods using Max() and Last() will become inaccurate beyond 2k items due to delegation issues. First(Sort... Will work no matter how many records are in the list.

  • PowerApps11 Profile Picture
    521 on at

    Hi @365-Assist and @Drrickryp 
    I have Sorted using this formula and tested on 10000 list and worked nicely getting me last ID also Drrickryp you right about will become inaccurate beyond 2k items due to delegation issues and am not a fun of collection 😡 as it would make, you're apps go very slow, actually all my apps are delegation free while filtering and getting what I need beyond 2k items including dates. 🤣   

    "Invoice # " &Text(First(FirstN(Sort(Test,ID,Descending),1)).ID+1,"[$-en-US]000500000")

    CaptureAc.PNG
    SharePoint
    CaptureSharepoint.PNG


    Thanks again both

  • PowerApps11 Profile Picture
    521 on at

    @Drrickryp 
    Is there a way to autoincrement the ID if saving bulk like multiple items? when patching?

    Text(First(FirstN(Sort(Test,ID,Descending),1)).ID+1,"[$-en-US]000500000")

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard