cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WeiMingLeong
Helper V
Helper V

expenses app to patch requestor from Expense List to lineitem List

Dear ALL,
Thank you for taking your time to see this message.


I am using the expense application and trying to patch selected rows from Lineitems List (RequestorLI - People picker column) from Expense List (RequestorName - People picker column)

WeiMingLeong_0-1663909173464.png

When an staff help someone (onbehalf) to submit for their expense/reimbursement.
Staff name will appear on Requestor (From) and that other person name will appear on Onbehalf.

Each Time after the approver, due to there is a displayname in the onbehalf, the Request name will be come the OnBehalf Name.

and will not patch if there is blank.

 

Expense List

IDTitleStatusDate SubmittedOnBehalfRequestor
30Sept 2022 claimPending18 Sept 2022Wei MingTest 1 user
31Sept 2022 claimPending18 sept 2022 Chris

 

What i have done is this and it only patch 1 selectedlineitems, it doesnt patch the other rows of selected items.

 

 

Patch(LineItems,LookUp(LineItems,ReportID.Id = SelectedReport.ID),
{RequestorLI:{'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims: "i:0#.f|membership|" & SelectedReport.OnBehalf.DisplayName,
                Department: "",
                DisplayName: "",
                Email: SelectedReport.OnBehalf.DisplayName,
                JobTitle: "",
                Picture: ""
            }
});

 

 

 

 

LineItem List

IDCategoryCurrencyCostDateReportIDRequestorLI
30Medical ClaimSGD802 sept 202230

Wei Ming

35TransportUSD4016 sept 202230Test 1 User ( i want this to also change to Wei Ming from the Expense list Requestor)

 

How can i make the patch to patch both 2 or more rows of selecteditems.

1 ACCEPTED SOLUTION

Accepted Solutions
AJ_Z
Super User
Super User

Following a call, we realised the solution is this:

 

AJ_Z_0-1667790449331.png

 



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

View solution in original post

10 REPLIES 10

@WeiMingLeong Did you try to use ForAll

 

//pseudocode
ForAll
(
   RecordsToPatch As MyItem
  ,Patch(MyDataSource,{MyColumn:MyItem.MyCol...) //pseudocode

)

 

I think you are not using any ComboBox, so the above by itself may help you and be enough.

 

If using a ComboBox SelectedItems or DefaultSelectedItems

 

If you are taking the values from a ComboBox, you may need to pay additional attention to some things.

While you can try using either YourComboBoxControl.DefaultSelectedItems or YourComboBoxControl.SelectedItems as the RecordsToPatch, note that sometimes, DefaultSelectedItems or SelectedItems might only contain some of the columns, such as only the main column and the unique identifier/primary key. If the primary key is still somehow in one of the columns of the SelectedItems, you can still retrieve the underlying record with a LookUp inside of the ForAll and perform the actual Patch based on the underlying record. So you may have to try something like the below instead, if this is your case, and if you do happen to run into this when using a ComboBox's SelectedItems or DefaultSelectedItems:

 

//pseudocode
ForAll
(
   ComboBoxControl.DefaultSelectedItems As MyItem
  ,With
   (
        {MyActualRecord:LookUp(MyDataSource,PrimaryKey = MyItem.PrimaryKey)}
       ,Patch(MyDataSource,{MyColumn:MyActualRecord.MyCol...) //pseudocode
   )

)​

 

 

The formulas are not tested and I do not know your column names or data source names, or the exact structure of your data. Check if you can use the above as a starting point, but you'll have to modify the formulas so they work in your scenario and app.

 

Check if anything above helps @WeiMingLeong 

Hi @poweractivate ,
Thank you for your reply.
i am trying ForAll, but i have error.

This function cannot operate on the same data source that is used in ForAll.

 

ForAll(LineItems,Patch(LineItems,LookUp(LineItems,ReportID.Id = SelectedReport.ID),
{RequestorLI:{'@odata.type':#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & SelectedReport.OnBehalf.DisplayName,
Department: "",
DisplayName: "",
Email: SelectedReport.OnBehalf.DisplayName,
JobTitle: "",
Picture: ""}
}));

 

WeiMingLeong
Helper V
Helper V

hi anyone else can help?

WeiMingLeong
Helper V
Helper V

Hi all, anyone can help me with this.?

@WeiMingLeong 

 

Try it like this instead:

//untested formula, modify the below as appropriate
With
(
    {MyActualRecord:LookUp(MyDataSource,PrimaryKey = MyItem.PrimaryKey)}
     ,Patch(MyDataSource, MyActualRecord,ComboBoxControl.SelectedItems) //pseudocode
)

Try not using a ForAll  in the first place, if possible

 

If you have to use ForAll make sure it is inside the Patch. It's better that way.

Put the ForAll here below if needed:

 

//untested formula, modify the below as appropriate
With
(
    {MyActualRecord:LookUp(MyDataSource,PrimaryKey = MyItem.PrimaryKey)}
     ,Patch(MyDataSource, MyActualRecord,ForAll(ComboBoxControl.SelectedItems As myComboBoxItem,...) //pseudocode
)
//replace ... above with what you want it to do for each Selecteditem of the Combo Box that will ultimately return a Table into ForAll, and that Table will be patched to MyAcutalRecord from MyDataSource

 

Does it work?

 

WeiMingLeong
Helper V
Helper V

@poweractivate 
i am not using combobox.


as i want it to patch using the Requestor (people column from Expenses sharepoint List) to selecteditems-Requestor (people column from LineItems sharepoint List)

 

WeiMingLeong
Helper V
Helper V

Bring this post up.
anyone can help me?

AJ_Z
Super User
Super User

Following a call, we realised the solution is this:

 

AJ_Z_0-1667790449331.png

 



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

WeiMingLeong
Helper V
Helper V

@AJ_Z ,

Thank you very much for your time to have a video call with me and solve my issue even it is late at night in your time zone.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,796)