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

Patch Collections & Custom Api | Update Etag with returned Api Etag

Hi guys,

 

I'm making a app for a production company. I have 2 issues with my patch method. 

 

  • varPatchRecord3 -> Outstanding Quantity is not updating in my Gallery wich is connected to my collection.
  • Last patch -> Returned Etag is not updating the current varThisItem.Etag

 

This is how the code works:

 

I have an icon in my gallery "productionList" wich has an "On select": Set(varThisItem,ThisItem)

 

This is my patch function:

 

Set(
    varPatchRecord,
    Patch(
        productionList,
        varThisItem,
        Defaults(productionList),
        {producedQuantity: varThisItem.producedQuantity + varAmount}
    )
);
Set(
    varPatchRecord3,
    Patch(productionList,
        varThisItem,
        Defaults(productionList),
        {outstandingQuantity: varThisItem.quantity - varPatchRecord.producedQuantity}
    )
);

Set(
    varPatchRecord2,
    MyFlow.Run(
        varThisItem.systemId,
        varThisItem.'@odata.etag',
        varPatchRecord.producedQuantity,
        varThisItem.productionFeedback,
        varPatchRecord3.outstandingQuantity
    )
);
    Patch(
        productionList,
        varThisItem,
        Defaults(productionList),
        {'@odata.etag': varPatchRecord2.'@odata.etag'}
    );

Set(
    varAmount,
    ""
);
Navigate(MainScreen)

 

  • The first patch is to patch the varThisItem.producedQuantity
  • The second patch i use varPatchRecord.producedQuantitiy for a calculation to patch the varThisItem.outstandingQuantity
  • The tirth patch i use my custom connector to run a flow wich will patch my custom Business Central table.
  • The last patch i want to update the varThisItem.Etag with the returned Etag from the Api Patch

 

Again the issues i have:

 

  • On return to the mainscreen: outstandingQuantity is not updated in the gallery nor the collection
  • When i wish to update this item again: Etag is not updated so i can't patch again.

I checked in Postman. The patch does work correctly the first time. producedQuantity and outstandinQuantity are correctly patched.

 

Also the returned Etag (varPatchRecord2.Etag) is correct i checked this. 

 

Can someone please help me with this?

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

so another update, i found out that the patch function is a little bit buggy in Powerapps. Especially combined with local collections. So i changed my patch function to an updateIf function and now it works fine!

 

UpdateIf(
    productionList,
    varEtag=varThisItem.'@odata.etag',
    {'@odata.etag': varPatchBusinessCentral.'@odata.etag'}
);

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Update.

 

I changed my code to:

 

Set(
    varPatchRecord,
    Patch(
        productionList,
        varThisItem,
        Defaults(productionList),
        {
            producedQuantity: varThisItem.producedQuantity + varAmount,
            outstandingQuantity: varThisItem.quantity - (varThisItem.producedQuantity+varAmount)
        }
    )
);
Set(
    varPatchRecord2,
    myFlow.Run(
        varThisItem.systemId,
        varEtag,
        varPatchRecord.producedQuantity,
        varThisItem.productionFeedback,
        varPatchRecord.outstandingQuantity
    )
);
Patch(
    productionList,
    varThisItem,
    Defaults(productionList),
    {'@odata.etag': varPatchRecord2.'@odata.etag'}
);
Navigate(MainScreen)

 

Now my outstandingQuantity does update in the gallery. However my varThisItem.Etag does not update to the new Etag i receive.

 

Any Ideas?

Anonymous
Not applicable

so another update, i found out that the patch function is a little bit buggy in Powerapps. Especially combined with local collections. So i changed my patch function to an updateIf function and now it works fine!

 

UpdateIf(
    productionList,
    varEtag=varThisItem.'@odata.etag',
    {'@odata.etag': varPatchBusinessCentral.'@odata.etag'}
);

View solution in original post

FCGALLEG
Community Support
Community Support

Hi AntonyDB,

 

Thanks for share the info with the Community.

 

Javier

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,342)