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 / How to make Max+1 for ...
Power Apps
Answered

How to make Max+1 for the Record Number While running Patch command

(0) ShareShare
ReportReport
Posted on by 2

I have written the below code while running the patch command, so that it can obtain max+1 for each records

RecoNo:(First(Sort(colAllWsOrders, RecoNo, SortOrder.Descending)).RecoNo)+1
 
But the records which is posted having one time max+1, 
I mean the max+1, was 15+1 = 16, so all the records which been posted have the 16 as the value of the RecoNo,
While it should be 16, for next 17, and so on.
 
Please advise, what changes I should do to the code to achieve this.

 

 

 

Full code:

ForAll(
GalleryCartOrder.AllItems,
Patch(
WsOrderTables, Defaults(WsOrderTables),
{
RecoNo:(First(Sort(colAllWsOrders, RecoNo, SortOrder.Descending)).RecoNo)+1,
RefJobNo:Upper(TextBox2_21.Value),
IssueForModel:Upper(TextBox2_26.Value),
IssueForSerial:Upper(TextBox2_27.Value),
LineExtPrice:ThisRecord.CostPrice*Value(CartQty.Value)
}
)
);

 

Categories:
I have the same question (0)
  • Verified answer
    QuentinDURIEZ Profile Picture
    577 Moderator on at

    Hi, 

     

     

    (First(Sort(colAllWsOrders, RecoNo, SortOrder.Descending)).RecoNo)+1

     

    This part of your formula is static since the number of items in colAllWsOrders 

     

    So to implement this correctly, you need to store the patched item into the said collection to have a +1 in each iterration

     

    ForAll(
    	GalleryCartOrder.AllItems,
    	
    	Collect(colAllWsOrders,
    		Patch(
    		WsOrderTables, Defaults(WsOrderTables),
    			{
    				RecoNo:(First(Sort(colAllWsOrders, RecoNo, SortOrder.Descending)).RecoNo)+1,
    				RefJobNo:Upper(TextBox2_21.Value),
    				IssueForModel:Upper(TextBox2_26.Value),
    				IssueForSerial:Upper(TextBox2_27.Value),
    				LineExtPrice:ThisRecord.CostPrice*Value(CartQty.Value)
    			}
    		)
    	)
    );

     

    I guess something like this should works. 

    Regards,

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard