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

Lookup and patch a form

Hi,

 

I have 2 SharePoint lists - "Header" and "Details". Both lists have an ID column, which is the ID column auto-generated by SharePoint.

 

On the Header list, I have a column called "Total". On the Details list, I have a column called "Item". I want to patch whatever is entered in Details list Item Column onto Header list Total column. The referencing column would be ID where if both IDs match, execute the patch. 

 

May I know what is the right way to write the Lookup portion of the Patch formula? Have been stuck at it for a while, and getting various errors. 

 

Thank you!

3 REPLIES 3
Community Support Team
Community Support Team

Re: Lookup and patch a form

Hi @elleeyl , 

Could you please share a bit more about the Patch formula you used in your app?

Do you want to auto-populate the Total column in Header List when you edit the "Item" column of a Details list record based on the ID column value?

 

I assume that you add a Edit form in your app to update the Detail List reocrd, is it true? I have made a test on my side, please take a try with the following workaround:

Set the OnSuccess property of the Edit form (EditForm1, which connects to your Detail List) to following:

Patch(
'Header Lst',
LookUp('Header Lst', ID = EditForm1.LastSubmit.ID), /* <-- Find the specific record in Header list based on the matching ID column value*/
{
Total: EditForm1.LastSubmit.Item
}
)

please take a try with above solution, then check if the issue is solved.

 

More details about the Patch function and LookUp function, please check the following article:

Patch function, LookUp function

 

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.
elleeyl
Level: Powered On

Re: Lookup and patch a form

Hi @v-xida-msft ,

 

Thanks for your response. Let me try to explain what I'm trying to do better.

 

Let's say I have 2 SP list.

This is my SP list 1 /Powerapps Screen 1; let's call it Header. "TotalClaimAmount" and "ReportID" are number fields.

header.PNG

This is my SP list 2 /Powerapps Screen 2; let's call it Details. "ExpenseType" is populated by a dropdown box, "ExpenseAmount" and "ParentID" are number fields. 

details.PNG

 

The idea is that once I Patch the details in Screen 1, ReportID would be generated in SP, and I would be brough to Screen 2 to fill in the details. In Screen 2, I would enter what I bought and how much I bought that item for. ParentID column here would be the same as ReportID column in Screen 1, as long as it is under the same Header. Once I am done with all the expense details, I would click on a "Submit" button (on Screen 2) which would sum up all the expense items under the same ParentID, and populate the total sum under TotalClaimAmont in Screen 1.

 

I tried the below formula on OnSelect button in Screen 2

 

Set(expenseamount,Value(DataCardValue44.Text));  /* <-- this is the individual value entered in Screen 2 under expense amount

Set(reportid, Last(Header).ReportID);  /* <-- this is used to populate the report ID  in Screen 1 onto Screen 2 for each individual expense

Patch(Details, Defaults(Details),{ParentID: reportid, Title: DataCardValue37.Text, ExpenseType: DataCardValue43.Selected, ExpenseAmount: Value(DataCardValue44.Text)}); /* <-- this is used to patch the ParentID, expensetype and expenseamount onto Details/Screen2

Patch(Header, LookUp(reportid=Details.parentid), {xxxxxxxx}) /* <-- this is used to sum all the individual expense amounts under the same ParentID under Details/Screen 2 and patch the total amount back under TotalClaimAmount of the same ID in Header/Screen 1.

 

May I know how I should write the formula for the last part, i.e. the patch formula to sum all the individual expense amounts of the same ParentID back onto the header list with the same ID?

 

I tried writing one but am getting invalid argument error. Thanks for your advice. Trying very hard to get unstuck. 🙂

Highlighted
elleeyl
Level: Powered On

Re: Lookup and patch a form

Hi, can anyone help me please? Thanks.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,696)