cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bbastro
Helper I
Helper I

Patch Combobox multiple items to a SP list lookup field

 I have a combo in powerapps that allow multiple items selection.  The combo box is added inside a gallery called"GalleryApproval".  The items value of this combo box is linked to a SharePoint list call "BQ-Failed Reason" and the default value of the combo box is "Thisitem.failed reason".  

In the "BQ-Failed Reason" SP list, other than the Id, there are fields called "Failed Reason" and "Importance".

 

I want to patch this combo box selected items to another SharePoint list called "BQ - Quality Submission List", and I have a lookup field setup in this SP list with allow multiple selections.

bbastro_1-1630398333552.png

 

With my code, I use the collection (ColFailedReason) to collect the items selected from the combo box, but I keep receive error with the Patch code.

 

ForAll(
ComboBoxReason.SelectedItems,
Collect(
ColFailedReason,
{
Id: ThisRecord.ID,Value:ThisRecord.'Failed Reason'}
)
);
Patch(
'BQ - Quality Submission List',
GalleryApproval.Selected,
{

'Failed Reason': ColFailedReason

}
);

bbastro_0-1630397959724.png

 

If anyone can help me with this error? 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @bbastro ,

As I said I was assuming some values as they were not clear from your post. What is the Items of your combo box?

As something else to think about, please read this blog of mine on data structure and ask yourself why you need to use a lookup column (I have not used them for many years) - Power Apps code is much easier without them,.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

7 REPLIES 7
PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @bbastro ,

 

Would you mind try the below ForAll in your code. Let me know if it helps

 

ForAll(
ComboBoxReason.SelectedItems,
Collect(
ColFailedReason,
Value:{'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                                ID: ThisRecord.ID
								Value: ThisRecord.'Failed Reason'
                        }
						))

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

WarrenBelz
Super User
Super User

Hi @bbastro ,

Free-typed and assuming some values, but have a go at this

Patch(
   'BQ - Quality Submission List',
   {ID:GalleryApproval.Selected.ID},
   {
      'Failed Reason':
      ForAll(
         ComboBoxReason.SelectedItems As aSel,
         {
            Value:aSel.Value,
            Id:aSel.Id
         }
      )
   }
}

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

But it doesn't identify "Value" at all

bbastro_0-1630399881488.png

 

With your suggestion, it seems collection is no longer required.  I tried your code but it is not able to get the aSel.Value and ASel.Id

bbastro
Helper I
Helper I

I am struggling with the error message "The type of argument "Failed Reason" does not match the expected type "Record". Found type "Table".

 

In the collection, it is going to be a table, since this is a multi-selected combo box, the collection store the selected ID and values.

In the patch function, I want to include those values in a single Sharepoint lookup field.  I get stuck here for a couple of days already.  Appreciate if someone can help.

Hi @bbastro ,

As I said I was assuming some values as they were not clear from your post. What is the Items of your combo box?

As something else to think about, please read this blog of mine on data structure and ask yourself why you need to use a lookup column (I have not used them for many years) - Power Apps code is much easier without them,.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Hi @WarrenBelz ,

Thanks for your advice, that's enlightened me!!!

My initial thought to using a lookup list may have benefits when I do Power BI reports later on.  However, it seems not necessary when I think through that once again.  I get the SP list field setup as single-line text field and concat the combo box values now and I am able to run the PATCH without any issue.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,122)