Hi All.
I got two tables.
Table 1 is the master table with data.
Table 2 is the request list... and these requests can be new rows, updates and deletion of rows.
And I have issues getting the updates to work.
I'm trying to use a Filtered ForAll forumla with a lookup function to identify which row to update... but I can't find the right row and when I tried to use disambigous reference it said I compared text to a table and in some cases I update only the first row (which is the wrong one).
I created a simple test area and this is the code I'm not getting to work:
ForAll(Filter(Var_test1, Change = true),
Patch(Var_test2,
LookUp(Var_test2,Var_test2[@Namn] = ThisRecord.Namn && Var_test2[@Yrke] = ThisRecord.Yrke)
,{Namn: Namn, Ålder: Ålder, Yrke: Yrke});
Patch(Var_test1,ThisRecord,{Change: false}));
Instead of ThisRecord I've also tried "Var_test1[@Namn]... with as little success.
Would be greatfull for some inputs...
Solved! Go to Solution.
Hi, it looks like you are using local collections, i have adjusted your formula, let me know if it works for you
ForAll(
Filter(Var_test1, Change = true) As MyItem,
Patch(Var_test2, {ID:
LookUp(Var_test2,[@Namn] = MyItem.Namn && [@Yrke] = MyItem.Yrke).ID}
,{Namn: MyItem.Namn, Ålder: MyItem.Ålder, Yrke: MyItem.Yrke});
Patch(Var_test1,MyItem,{Change: false}));
Hi, it looks like you are using local collections, i have adjusted your formula, let me know if it works for you
ForAll(
Filter(Var_test1, Change = true) As MyItem,
Patch(Var_test2, {ID:
LookUp(Var_test2,[@Namn] = MyItem.Namn && [@Yrke] = MyItem.Yrke).ID}
,{Namn: MyItem.Namn, Ålder: MyItem.Ålder, Yrke: MyItem.Yrke});
Patch(Var_test1,MyItem,{Change: false}));
Yes, I usually use collections when I need to experiment, so easy to set up... the original problem is in Sharepoint... but think I can solve it once I solve this one.
And I think I just did, thanks to your input.
Renaming the Filteration worked like a charm... but I had to remove the ID part and also the [@] part.
So the final code that worked is:
ForAll(
Filter(Var_test1, Change = true) As MyItem,
Patch(Var_test2,
LookUp(Var_test2,Namn = MyItem.Namn && Yrke = MyItem.Yrke)
,{Namn: MyItem.Namn, Ålder: MyItem.Ålder, Yrke: MyItem.Yrke});
Patch(Var_test1,MyItem,{Change: false}));
And with a little adjustment it worked perfect in the original Sharepoint list aswell.
Except... The second Patch isn't accepted... so I can't change the status of the "request" simultanious.
It says I can't update the record in the ForAll loop?
Ofcourse the status can be changes after... but I would really like to do it simultaneous as only those lines actually processed would be updated
Is there a way to solve this?
i just realised your filter criteria is what you are trying to update, if you collect you filter first it might work, I'm un able to test at the minute but give the below a try:
ClearCollect(Col_Filter_Results,Filter(Var_test1, Change = true))
;ForAll(Col_Filter_Results As MyItem,
Patch(Var_test2, {ID:
LookUp(Var_test2,[@Namn] = MyItem.Namn && [@Yrke] = MyItem.Yrke).ID}
,{Namn: MyItem.Namn, Ålder: MyItem.Ålder, Yrke: MyItem.Yrke});
Patch(Var_test1,{ID:MyItem.ID},{Change: false}));
Ahh Thanks... so I need to create a collection of the desired changes to be able to update the original post directly.
Sounds logical.
Got the other code to work atm... but I will try this next time I make an update 🙂
Thanks!
User | Count |
---|---|
119 | |
87 | |
86 | |
75 | |
66 |
User | Count |
---|---|
214 | |
181 | |
139 | |
96 | |
83 |