cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Ascawath
Level: Power Up

Powerapps update LookUp Column (multi-select)

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 ,

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Powerapps update LookUp Column (multi-select)

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

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Powerapps update LookUp Column (multi-select)

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

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Ascawath
Level: Power Up

Re: Powerapps update LookUp Column (multi-select)

Hi,

Thanks for your reply.
I took the second way.
I thought collect adds a new item to a collection and regarding to a table or list, collect would add this item directly to the list/table.

Thanks for your help

And kind regards

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
Users Online
Currently online: 205 members 6,415 guests
Please welcome our newest community members: