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)
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
ID | Title | Status | Date Submitted | OnBehalf | Requestor |
30 | Sept 2022 claim | Pending | 18 Sept 2022 | Wei Ming | Test 1 user |
31 | Sept 2022 claim | Pending | 18 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
ID | Category | Currency | Cost | Date | ReportID | RequestorLI |
30 | Medical Claim | SGD | 80 | 2 sept 2022 | 30 | Wei Ming |
35 | Transport | USD | 40 | 16 sept 2022 | 30 | Test 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.
Solved! Go to Solution.
Following a call, we realised the solution is this:
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:
@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: ""}
}));
hi anyone else can help?
Hi all, anyone can help me with this.?
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?
@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)
Bring this post up.
anyone can help me?
Following a call, we realised the solution is this:
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:
@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.
User | Count |
---|---|
252 | |
104 | |
94 | |
50 | |
39 |