cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Patching To Parent/Child Records

Hi All,

I have an issue which I cannot get my head around. I have two SPO lists, Orders & ItemsInOrder. I have a "shopping cart" system, whereby I create orders in one list, but the items themselves are in the second list and are referenced to an Order ID.

 

I am able to update the status of each item independently (each item can be marked as "on hold", "declined" etc) and this works well. What I am wanting to do is have the system patch the Order to the same status if all of the items are marked the same, so for example if all items are marked "on hold" the Order itself will be marked as on hold. I have two galleries, the first one is the gallery of orders and the second is those items linked to that order. Can anyone advise of how I could do this? I use a variable to set the selected Order for patching.

 

My patch for the OrderItems is: ForAll(Gallery7.AllItems,Patch(ItemsInOrder,{ID:ID},{ItemInOrderStatus:Dropdown2.Selected.Value}))

 

Thanks,

 

Chris

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Could you please share a bit more about your scenario?

Could you please show more details about the variable that you mentioned? Could you please share more details about the formula you used within the Items property of the second Gallery? Does the Gallery7 represent the second Gallery?

 

Based on the formula you provided, I think you use this Patch formula to update the Order Items status in your second Gallery (Gallery7), is it true?

 

Based on the needs that you mentioned, I think a Timer control could achieve your needs. I have made a test on my side, please take a try with the following workaround:

Add a Timer control in your app, set the Duration property to following:

1000

set the AutoStart and Repeat property to following:

true

set the OnTimerEnd property of the Timer to following:

If(
    CountRows(Filter(Gallery7.AllItems, ItemInOrderStatus = First(Gallery7.AllItems).ItemInOrderStatus)) = CountRows(Gallery7.AllItems),
Patch(
'Orders List',
FirstGallery.Selected, /* or type LookUp('Orders List', ID = FirstGallery.Selected.ID) */
{
OrderStatus: First(Gallery7.AllItems).ItemInOrderStatus /* <-- OrderStatus represents the Status column in your Orders List, which is used to store the status value */
}
) )

Note: The FirstGallery represents the first Gallery in your app, which connects to the Orders SP List.

If the OrderStatus column in your Orders List is Choice type column, please consider modify above formula as below:

If(
    CountRows(Filter(Gallery7.AllItems, ItemInOrderStatus = First(Gallery7.AllItems).ItemInOrderStatus)) = CountRows(Gallery7.AllItems),
Patch(
'Orders List',
FirstGallery.Selected, /* or type LookUp('Orders List', ID = FirstGallery.Selected.ID) */
{
OrderStatus: {
Value: First(Gallery7.AllItems).ItemInOrderStatus
}
}
) )

 

Set the Visible proeprty of the Timer to following:

false

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
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

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Could you please share a bit more about your scenario?

Could you please show more details about the variable that you mentioned? Could you please share more details about the formula you used within the Items property of the second Gallery? Does the Gallery7 represent the second Gallery?

 

Based on the formula you provided, I think you use this Patch formula to update the Order Items status in your second Gallery (Gallery7), is it true?

 

Based on the needs that you mentioned, I think a Timer control could achieve your needs. I have made a test on my side, please take a try with the following workaround:

Add a Timer control in your app, set the Duration property to following:

1000

set the AutoStart and Repeat property to following:

true

set the OnTimerEnd property of the Timer to following:

If(
    CountRows(Filter(Gallery7.AllItems, ItemInOrderStatus = First(Gallery7.AllItems).ItemInOrderStatus)) = CountRows(Gallery7.AllItems),
Patch(
'Orders List',
FirstGallery.Selected, /* or type LookUp('Orders List', ID = FirstGallery.Selected.ID) */
{
OrderStatus: First(Gallery7.AllItems).ItemInOrderStatus /* <-- OrderStatus represents the Status column in your Orders List, which is used to store the status value */
}
) )

Note: The FirstGallery represents the first Gallery in your app, which connects to the Orders SP List.

If the OrderStatus column in your Orders List is Choice type column, please consider modify above formula as below:

If(
    CountRows(Filter(Gallery7.AllItems, ItemInOrderStatus = First(Gallery7.AllItems).ItemInOrderStatus)) = CountRows(Gallery7.AllItems),
Patch(
'Orders List',
FirstGallery.Selected, /* or type LookUp('Orders List', ID = FirstGallery.Selected.ID) */
{
OrderStatus: {
Value: First(Gallery7.AllItems).ItemInOrderStatus
}
}
) )

 

Set the Visible proeprty of the Timer to following:

false

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-xida-msft Thank you, thats worked brilliantly.

 

Many Thanks,

 

Chris

Helpful resources

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

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,411)