Hi,
I'm trying to update my SharePoint list order which contains a lookup column named positions.
positions itself contains some data of one order position. In list order the column positions is multi selectable.
So my next step is to add a new item to positions regarding to an item in order.
That is why I want to update the multi-select lookup column in order with the new added item of positions, so that the values before updating are still in that column plus the new added one.
NID and PID are global variables.
I tried with patch:
Patch( LookUp( order; ID = NID; positions ); Defaults( LookUp( order; ID = NID; positions ) ); { Id: PID; Value: LookUp( positions; ID = PID; toShow ) } )
and I also tried with collect
Collect( LookUp( order; ID = NID; positions ); { '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"; Id: PID; Value: LookUp( positions; ID = PID; toShow ) } )
To test I saved the current item in a context variable. With both methods for the context variable that works fine.
But the changes won't update to the actual SharePoint list.
Mysteriously this piece of code worked but merged only the first item with the new one (obviously)
Patch( order; First( Filter( order; ID = NID ) ); { positions: Table( First( LookUp( order; ID = NID; positions ) ); { Id: PID; Value: LookUp( positions; ID = PID; toShow ) } ) } )
Is there some hidden woodo magic missing?
Thanks in advance
PS.: the ; are correct here instead of the normal ,
Solved! Go to Solution.
Hi @Ascawath ,
Do you want to update a multiple look-up column?
If you want to use the original data, I suggest you two ways:
1)use edit form
Set the edit form's Item:
First( Filter( order; ID = NID )
Set the edit form's DefaultMode: FormMode.Edit
The multiple look-up column's combo box's DefaultSelectedItems: Parent.Default (this will load the original data)
Set the multiple look-up column's datacard's Update: DataCardValue16.SelectedItems
2)save the original data as a collection
ClearCollect(test;First( Filter( order; ID = NID ).posotions //save the original data as a collection
Collect(test,{Id: PID;Value: LookUp(positions;ID = PID;toShow)}) // save the new data to the save collection
Patch(order;
LookUp( order; ID = NID );
{positions:test}
)
Use the function of patch will not save the original data.
That's the reason why I use collection.
I think maybe you need to kown more about patch.
Here's a doc about if for your reference:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch
Best regards,
Community Support Team _ Phoebe Liu
Hi @Ascawath ,
Do you want to update a multiple look-up column?
If you want to use the original data, I suggest you two ways:
1)use edit form
Set the edit form's Item:
First( Filter( order; ID = NID )
Set the edit form's DefaultMode: FormMode.Edit
The multiple look-up column's combo box's DefaultSelectedItems: Parent.Default (this will load the original data)
Set the multiple look-up column's datacard's Update: DataCardValue16.SelectedItems
2)save the original data as a collection
ClearCollect(test;First( Filter( order; ID = NID ).posotions //save the original data as a collection
Collect(test,{Id: PID;Value: LookUp(positions;ID = PID;toShow)}) // save the new data to the save collection
Patch(order;
LookUp( order; ID = NID );
{positions:test}
)
Use the function of patch will not save the original data.
That's the reason why I use collection.
I think maybe you need to kown more about patch.
Here's a doc about if for your reference:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch
Best regards,
Community Support Team _ Phoebe Liu
User | Count |
---|---|
155 | |
98 | |
88 | |
78 | |
58 |
User | Count |
---|---|
189 | |
182 | |
107 | |
96 | |
91 |