cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kevin_Maxwell
Level: Powered On

Patch values to SharePoint Lookup column

I have a collection called "Beneficiary_Collection" and a sharePoint list called "Beneficiary". In SharePoint list I have a Lookup column called "Conditions" which it allows Multiple Values to be saved (in SP, Allow multiple values is enabled).

 

Collection has the following values for ID = "50114": AcceptableActive

 

I'm using the following code to Patch multiple values to SP Conditions column:

 

ForAll(Beneficiary_Collection,
Patch(Beneficiary,LookUp(Beneficiary, Beneficiary_ID = "50114"),
{
    Conditions: Table(
    {
           '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
           Id: LookUp(Conditions_Lookup, English_Def in Conditions.English_Def, ID),
           Value: LookUp(Conditions_Lookup, English_Def in Conditions.English_Def, English_Def)
           
    })
}))

 

But the problem is that it only saves the first row/value which is Acceptable. My question is, how can I loop/read/insert every value in Collection?

 

I also tested the following which is the manual way, it works but I don't know how to make this automatic.

 

 

Conditions: Table(
    {
           '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
           Id: 1,
           Value: "Acceptable"      
    },
    {
           '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
           Id: 5,
           Value: "Active"         
    })

 

Following are the end results:

 

  • This is how it looks in SP when I use the second way (manual):

1.JPG

  • This is how it looks in SP when I use the first way (automatic):

2.JPG

 

 

 

 

 

 

 

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Eickhel
Level 8

Re: Patch values to SharePoint Lookup column

Hey,

 

You were on the right track. I'm using a Dropdown for multiple values and they way I got it working is like this:

 

Conditions: ForAll(ConditionsDropdown.SelectedItems, {
                '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                Id: LookUp(Conditions_Lookup, English_Def in Conditions.English_Def, ID),
                Value: LookUp(Conditions_Lookup, English_Def in Conditions.English_Def, English_Def)
            })

 

Just change "ConditionsDropdown.SelectedItems" to your conditions list.

View solution in original post

9 REPLIES 9
Eickhel
Level 8

Re: Patch values to SharePoint Lookup column

Hey,

 

You were on the right track. I'm using a Dropdown for multiple values and they way I got it working is like this:

 

Conditions: ForAll(ConditionsDropdown.SelectedItems, {
                '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                Id: LookUp(Conditions_Lookup, English_Def in Conditions.English_Def, ID),
                Value: LookUp(Conditions_Lookup, English_Def in Conditions.English_Def, English_Def)
            })

 

Just change "ConditionsDropdown.SelectedItems" to your conditions list.

View solution in original post

Highlighted
Kevin_Maxwell
Level: Powered On

Re: Patch values to SharePoint Lookup column

@Eickhel Thank you for your reply. I tried your method and it works now. I did the following:

 

 

 

Conditions:
    ForAll(Conditions, {
                '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                Id: LookUp(Conditions_Lookup, English_Def in Conditions[@English_Def], ID),
                Value: LookUp(Conditions_Lookup, English_Def in Conditions[@English_Def], English_Def)
    })

 

Rajesh
Level: Powered On

Re: Patch values to SharePoint Lookup column

I'm trying something similar. I've a cascade dropdown which allows multiple values. The first dropdown user makes a selection and the second dropdown filters based on the selection made in the first dropdown. User can select multiple values in the second dropdpwn. I'm trying to Patch the selected values into a SharePoint lookup column. But I'm getting a server returned error from SharePoint. This is how I'm trying to pass the data. Say my first dropdown is Region and second is CustomerCountry mapped to column CustomerCountry in Customers list. CustomerCountry is a lookup  to Country column in Countries list

 

ForAll(DropDown2.SelectedItems, {
'@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: LookUp(Countries, Country=CustomerCountry).ID,
Value: LookUp(Countries, Country=CustomerCountry).Country 

})

 

Is there any issue with my syntax above? How do I get reference to each of the selected value in the second dropdown that I can use to filter the lookup list to get the ID? 

Rajesh
Level: Powered On

Re: Patch values to SharePoint Lookup column

I managed to solve this. It appears PowerApps supports multi valued lookup currently and there's no need to use Patch function. PowerApps sends the SelectedItems. For the casdading lookup to work all I had to do was to modify the Items collection with a filter to Choices collection.

 

Filter(Choices('Customers'.CustomerCountry), Id in Filter('Countries',Region=Dropdown1.Selected.Value).ID)

Anonymous
Not applicable

Re: Patch values to SharePoint Lookup column

Great I was searching for this from 2 days!!!!!! Thanks a lot for your answer

simkessy
Level: Powered On

Re: Patch values to SharePoint Lookup column

How did you do it? I'm having issues patching a multi-lookup from a combobox 


@Anonymous wrote:

Great I was searching for this from 2 days!!!!!! Thanks a lot for your answer


 

Anonymous
Not applicable

Re: Patch values to SharePoint Lookup column

Actually I did not go with Patch used below function Filter(Choices('Customers'.CustomerCountry), Id in Filter('Countries',Region=Dropdown1.Selected.Value).ID)
And used SubmitForm(FormName) to save the form data
simkessy
Level: Powered On

Re: Patch values to SharePoint Lookup column

Is that because it's not possible to patch a multi-lookup?

 

I have a combo box I was trying to patch into a multi-lookup but I can't find any good resources on how to do this.

porpower
Level: Powered On

Re: Patch values to SharePoint Lookup column

@Rajesh You saved my day!!!

Helpful resources

Announcements
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

thirdimage

Power Apps 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

Top Solution Authors
Top Kudoed Authors
Users online (5,240)