cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
turtle21
Regular Visitor

Using variable to choose item from Lookup Column of Sharepoint List

Hello,

I'm trying to build an item rental recording app, in which users choose one or more buttons to select items and submitform(since there's a SharePoint list form) will add a new record(or should I say list item?) to the SharePoint list.

Submitting a single item process is succeeded, but now I'm completely stuck with multiple selections from a lookup column in PowerApps...

 

I tried using a combobox, and it's successful when choosing only one item, by writing this in the DefaultSelectedItem property in the combobox.

 

{
  '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", 
  Id: VariableA, 
  Value: LookUp(ListB,ID=VariableA).ColumnB
}

 

 

However, it didn't work when it comes to multiple selections, although I'm setting multiple selections

I tried to add collect several VariableA into CollectionA and edit DefaultSelectedItem property as follows:

 

ForAll(CollectionA,
{
  '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", 
  Id: CollectionA.Value,
  Value: LookUp(ListB,ID=CollectionA.Value)
}
)

 

With this code, there's an error, which says now it's a comparison of number(ID) and table(CollectionA.Value). Now I have no idea how I can solve this error.

 

What I want to do is to use a variable to multi-select lookup column from SharePoint list.

Using ComboBox, several DropDown, Collection, Gallery.... any process is fine.

Any help would be highly appreciated.

 

I have two Sharepoint Lists, which are...

ListA: with several columns including one LookUp Column, referring to ListB's column

ListB: also with several columns and one of them is ColumnB, a calculated column(from a few other columns' texts into a line column), which is the one referred from ListA

and

VariableA: ID of the selected item in the ListB. Each item's ID is assigned to this variable when selecting each button.

CollectionA:Collection of VariableA

 

Thank you in advance!!

2 ACCEPTED SOLUTIONS

Accepted Solutions
turtle21
Regular Visitor

looks like I made mistake when writing 2nd code. now the collection version works!!

 

 

Collect(CollectionA,
{
  '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", 
  Id: VariableA,
  Value: LookUp(ListB,ID=VariableA).ColumnB
}
)

 

 

 

View solution in original post

turtle21
Regular Visitor

I stop using submit form since I keep errors again and again although it did work.

Since I changed from submitting form to using “Patch”, I finally reach my goal of creating a new record with multiple selections of SharePoint lookup column.

Patch(ListA,
Defaults(ListA),

then write down what to input in each column, and I used a collection variable as one of the columns' value, and it did work perfectly.

View solution in original post

3 REPLIES 3
turtle21
Regular Visitor

looks like I made mistake when writing 2nd code. now the collection version works!!

 

 

Collect(CollectionA,
{
  '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", 
  Id: VariableA,
  Value: LookUp(ListB,ID=VariableA).ColumnB
}
)

 

 

 

turtle21
Regular Visitor

well, I thought it works, and it did work, but actually, now it doesn't work...

I tried to write Collect(CollectionA,...) code in each item's button, instead of having a different button only for collect, but I'm wondering maybe that could be the reason why it doesn't work completely...

(Then I cannot understand why it doesn't work even though I recovered the previous version as the newest...)

 

Is anyone can make this work every time...?

sorry for asking many times...

turtle21
Regular Visitor

I stop using submit form since I keep errors again and again although it did work.

Since I changed from submitting form to using “Patch”, I finally reach my goal of creating a new record with multiple selections of SharePoint lookup column.

Patch(ListA,
Defaults(ListA),

then write down what to input in each column, and I used a collection variable as one of the columns' value, and it did work perfectly.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (4,206)