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 / Run a patch statement ...
Power Apps
Answered

Run a patch statement in powerapps multiple times based on a number against the sharepoint item

(0) ShareShare
ReportReport
Posted on by 333

Hi all,

 

I am hoping for some help with the following concept;

 

I have a list that is designed to receive in stock. Stock arrives on pallets and in the system, I can list how many pallets are delivered.

From a receival point of view, each SharePoint item equates to one order, with each order possibly having multiple pallets of stock.

Stock is initially received into a quarantine section until approved for use, at which point it is then stored in shelving.

When it comes time to store the stock, the shelving has a grid system e.g. A1, A2, A3 with one pallet per section. What I would like to do, is when the user marks a receival as completed, if the order has say 3 pallets of stock, it patches to a SharePoint list, the same data 3 times. This way, when the stock is to be allocated to a shelf, it is done per pallet. Below is an illustration/diagram that hopefully helps explain;

 

storage solution.png

 

At this stage the button used for patching is sitting inside a gallery. The number of pallets is listed in a TextInput control. If I can get the OnSelect of the patch button to look at the number of pallets and then patch that many times, it would help with automating the process.

 

Any help would be greatly appreciated.

 

Thanks!

Categories:
I have the same question (0)
  • Vijay Tailor Profile Picture
    2,961 on at

    Hi @BrendanZ1 ,

    You can use the ForAll Function and use the Patch so, ForAll Loop every record.

    you can use code Like below.

    ForAll(TimesheetDateEntryCollection,
    If(!IsBlank(Title) && Value(WorkingHours)>0,
    Patch(TimeSheetEntryBook,
    Defaults(TimeSheetEntryBook), //if you need to patch New Record //if you need to update existing record then Modify the code for Patch and Pass the ID for This record.
    {
    Title:Text(Form2.LastSubmit.Title,"[$-en-US]m/d/yyyy"), //if Text Column you need to patch
    'Project Name':{ //if Look Up COlumn need to Patch
     Id:ProjectID,
     Value: Project,
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
     },
     WorkType:{
     
     Value: WorkType,
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
     },
    
    MasterID:Form2.LastSubmit.ID, //Master ID 
    
     
    })));

    Thanks,
    Vijay

    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay


     

  • BrendanZ1 Profile Picture
    333 on at

    Thanks @VijayTailor for taking the time to help, but I feel you solution doesn't match with what I am trying to achieve. I have used the ForAll and Patch function for a number of solutions in my apps, but this is more about telling the app to make a copy of a record in one list, and put it in another, but do this 'X' amount of times, based on a numerical input in the app.....

    So from a workflow perspective, when someone clicks on a button, it's OnSelect does the following; Patch 'X' data to SP List 1, then based on the number in TextInput1 Control, create that many records in SP List 2 patching 'X' data there.

     

    Kind of like telling the app to run a Patch function 'X' amount of times and then stop.......

  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @BrendanZ1 ,

    Do you want to update one record in list1 and create multiple records based on data in two textinputs?

    Based on your description, I think the app's layout should be like this:

    10161.PNG

     List2 has two fields, one comes from the first part that I circled, the second one comes from the the first part that I circled+the third part that I circled.

    Data is like this:

    order1       pallet1

    order1       pallet2

    order1       pallet3

     

     

    If so, you could set the button to patch data like this:

    Patch(list1,ThisItem,{stockname:TextInput1.Text,barcode:TextInput2.Text,quantity:Value(TextInput3.Text)});
    Collect(list2,AddColumns(
     Sequence(Value(TextInput3.Text)), //quantity textinput
     "order",Label1.Text, //the first part
     "product",TextInput1.Text&Value //the second part+ auto number
     )
     )

     

     

    I suggest you know more about Sequence function:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-sequence

     

     

     

    Best 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 387

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 301

Last 30 days Overall leaderboard