cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BrendanZ1
Helper V
Helper V

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

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!

1 ACCEPTED SOLUTION

Accepted Solutions

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
VijayTailor
Resident Rockstar
Resident Rockstar

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


 

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

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (71,640)