cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GordonFreeman33
Regular Visitor

Sending collection to matching SP lists - not working

Hi everyone, (First Time posting)

 

Some context:

I have an inventory app, and when people add the products from a delivery, they add each item to a collection (colProducts) before submitting their items to two matching SP lists. One SP is meant to remove quantities (InventoryTracker), and the other is intended to be the archive of all products (OrdersReceived) that have come into the warehouse.

 

My Dilemma:

Would anyone know why some records don't go to BOTH lists every time? Most times, they end up in the "OrdersReceived" (archives) list, but not always the "InventoryTracker" list.

 

Fomula: 

Patch(InventoryTracker,colProducts);
Collect(OrdersReceived,colProducts);
Reset(txtSearchInvoice_1);
ResetForm(FormPOitems_1);
Reset(Checkbox1_2);
Navigate(Home);
Clear(colProducts);

 

Would a FLOW be a better option?  Thank you in advanced!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @GordonFreeman33 ,

I assume the field names are the same as the List here - also Patch the table, not loop through - it is much faster

Patch(
   InventoryTracker,
   ForAll(
      colProducts As aPatch,
      {
         Arrived: aPatch.Arrived, 
         Product: aPatch.Product, 
         Customer: aPatch.Customer,
         ...
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

9 REPLIES 9
WarrenBelz
Super User
Super User

Hi @GordonFreeman33 ,

To use

Patch(
   InventoryTracker,
   colProducts
)

the fields in colProducts need all to be in InventoryTracker and you should have the ID (I am assuming you are using SharePoint here) in colProducts, so the existing items can be updated. Is this the case?

Hi @WarrenBelz.,

im actually using 

Patch(
   InventoryTracker,
   colProducts
)

to create new records in my SharePoint List. I understand Patch is used to update records, but i recently changed it from

Collect(InventoryTracker,colProducts)

 in efforts to fix the problems im having with the collection not going to InventoryTracker.

Hi @GordonFreeman33,

Patch also should work (I thought the difference was updating as you used Collect in the other one). There is something strange here if OrdersReceived works on Collect and InventoryTracker does not if all the fields in colProducts (both name and type) are in InventoryTracker and there are no compulsory fields in InventoryTracker not in colProducts (and I assume you get no errors on either the code or the Patch). Is all of this correct?

 

@WarrenBelz. You are correct. colProducts always goes to OrdersReceived and to InventoryTracker about 95% of the time. It's very hit and miss. Not sure why.

Both SharePoint lists are identical, and there aren't any required fields in either of them. 

Any Advice?

HI @GordonFreeman33 ,

To be honest, I have experienced the same thing (occasional failure) on collections with a large number of fields - I just go back to doing it "the long way" and lining up the fields on each side - a bit of coding but works every time.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

 

Hi @WarrenBelz. So would a formula like this be best:

 

ForAll(colProducts,Patch(InventoryTracker,Defaults(InventoryTracker),{Arrived:colArrived, Product:colProduct, Customer:colCustomer,...})

 

I really appreciate your help with this issue. Thank you!

Hi @GordonFreeman33 ,

I assume the field names are the same as the List here - also Patch the table, not loop through - it is much faster

Patch(
   InventoryTracker,
   ForAll(
      colProducts As aPatch,
      {
         Arrived: aPatch.Arrived, 
         Product: aPatch.Product, 
         Customer: aPatch.Customer,
         ...
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hi @WarrenBelz I'll give this a try and let you know if it works. Thank you!

@WarrenBelz. It's been close to a week and everything seems to be working fine so far. Thank you again. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,387)