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

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
    547 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

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard