cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bpg950
Level: Powered On

Forall and Patch - Patched values repeating.

Hi -

 

Trying to make an app for processing uniform orders.  I have a collection (UniformOrder) patching selected items to a SharePoint List (Uniform_Orders).  I am able to successfully patch, but it repeats the last item in the collection for as many items as are in the Collection.

 

What I am doing wrong?

 

ForAll(
UniformOrder,
Patch(
Uniform_Orders,
Defaults(Uniform_Orders),
{
Item_Description: CartItemName.Text,
Qty: CartQty.Text,
Size_Info: CartSizeInfo.Text,
Requestor: User().FullName,
}
)
)

5 REPLIES 5
Super User
Super User

Re: Forall and Patch - Patched values repeating.

I am not sure if I understand the issue. The formula looks like it is creating one new item in SharePoint for each record in the UniformOrder collection. Is this what it is doing and if so, what do yo want it to do?



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Super User
Super User

Re: Forall and Patch - Patched values repeating.

When you use defaults() in a Patch() statement it creates a new record.  That's why you are getting duplicates.  YOu need to replace the defaults() statement with something that identifies the specific record being Patched. This Blog post discusses how to do BAtch updates using Forall and patch.

https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
bpg950
Level: Powered On

Re: Forall and Patch - Patched values repeating.

I am using it like a shopping cart.  They are selecting items from a gallery, adding them to the Collection (UniformOrders).  I then want to add each of their selected items to a SharePoint list (Uniform_Orders).  

Super User
Super User

Re: Forall and Patch - Patched values repeating.

Can you share the schema for the collection and the SharePoint list?  There needs to be a way to uniquely identify the records in the list that need to be each of the records in the collection.  Otherwise the patch won't work.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
bigeldm
Level: Powered On

Re: Forall and Patch - Patched values repeating.

 

I am using something almost exactly like what you have and I don't have the problem.  Here is what I am using if it helps at all.

 

The RequestID is a unique identifier created for each record - you need a value to uniquely identify each record.


ForAll(AddressCollection,

Patch('[dbo].[MDM_VENDOR_REQ_ADDR]',

Defaults('[dbo].[MDM_VENDOR_REQ_ADDR]'), {VREQ_ID: Value(RequestID), ADDR_TYP: ADDR_TYP, ADDR_BLDGNBR_POBOX: ADDR_POBOX, ADDR_PCODE: ADDR_PCODE , ADDR_CITY: ADDR_CITY, ADDR_RGN: ADDR_RGN, ADDR_CNTRY: LookUp(CountryList, ADDR_CNTRY = Country_Name, code_2), ADDR_LINE1: ADDR_LINE1, ADDR_LINE2: ADDR_LINE2}));

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 82 members 3,170 guests
Please welcome our newest community members: