cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kevin_Maxwell Advocate I
Advocate I

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
Highlighted
Eickhel Responsive Resident
Responsive Resident

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

10 REPLIES 10
Highlighted
Eickhel Responsive Resident
Responsive Resident

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

Kevin_Maxwell Advocate I
Advocate I

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 Advocate II
Advocate II

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 Advocate II
Advocate II

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 Helper I
Helper I

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 Helper I
Helper I

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
Regular Visitor

Re: Patch values to SharePoint Lookup column

@Rajesh You saved my day!!!

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

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