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

Combo box patch multiple selections from a unique list

I have 2 SharePoint lists that feed into an App:

  • Lookup List - maps the cascading dropdown choices in PowerApps. Some fields in the SP list (and type) include:
    • TeamName (single line of text)
      • Appears as a dropdown in PowerApps
    • StandardGroups (single line of text)
      • Appears as a combo box in PowerApps - based on the TeamName selection, certain StandardGroups will appear
  • Tickets List - where we Patch data from PowerApps back to. Some fields in the SP list (and type) include:
    • TeamName (choice, single-select -- the only choice in SP is "1", no quotes)
    • StandardGroups (choice, multi-select -- the only choice in SP is "1", no quotes)
      • The reason we use "1" is because the gold copy list of what those choices should be are maintained in the Lookup List, so we don't have to maintain the lists in 2 places.

 

The dropdown containing the Team is patching as expected - no issues there.

The problem is the combo box that contains the StandardGroups - it's called "cmb_standardgroups_newuser" in the App (the "_newuser" is just the name of the screen in the App). See below for the different iterations of the code I've tried so far.

 

I'm trying to avoid adding the StandardGroups maintained in the Lookup List to the StandardGroups in the Tickets List because there are 860 different selections (!!). That said...if that's my ONLY option to make this work, then so be it.

 

Thanks in advance for the help!

 

Patch('Tickets List',Defaults('Tickets List'),
{Team: dd_team_newuser.SelectedText},
{StandardGroups: cmb_standardgroups_newuser.Selected.Result})

Also tried:
{StandardGroups: cmb_standardgroups_newuser.Selected.Value}
{StandardGroups: cmb_standardgroups_newuser.SelectedItems}
{StandardGroups: cmb_standardgroups_newuser.SelectedItems.Value}
{StandardGroups: cmb_standardgroups_newuser.SelectedItems.Result}
{StandardGroups: ForAll(cmb_standardgroups_newuser.SelectedItems,{Value: 'Lookup List'.'StandardGroups'})}
{StandardGroups: ForAll(cmb_standardgroups_newuser.SelectedItems,{Value: 'Lookup List'.StandardGroups})}

 

1 ACCEPTED SOLUTION

Accepted Solutions

Alright - so - after doing A LOT more research, I found one of @Shanescows videos that got me to the solution.

 

Recall that the problem --> unable to Patch a new record to SharePoint due to combo boxes Items property.

 

Solution --> Using the example I provided (cmb_favoritefood_newitem), here's what I used for the Items property (again - all credit goes to Shane on this!)

RenameColumns(Distinct(Filter('Mapping Table', Category = dd_foodcategory_newitem.Selected.Value),Item), "Result", "Value")

 

So this formula is pulling the Item column from the Mapping Table, but it's only returning based on what's filtered in the Category field. It comes through as "Result" which doesn't play nice with Patch apparently.  Using RenameColumns was INSTRUMENTALLY helpful:

Patch('Tickets List',Defaults('Tickets List'),
{'Food Category': dd_footcategory_newuser.SelectedText},
{'Favorite Food': ForAll(cmb_favoritefood_newuser.SelectedItems, {Value: Value})}
)

 

Thank you again Shane!!!

View solution in original post

3 REPLIES 3
BCLS776
Super User
Super User

A combobox with multiple selections enabled produces a table (even with only one choice), so you have to Patch() more than one record with something like this:

 

ForAll(cmb_standardgroups_newuser.SelectedItems As aItem,
    Patch('Tickets List',Defaults('Tickets List'),
        {
            Team: dd_team_newuser.SelectedText,
            StandardGroups: aItem.Result // Assuming Result is the correct name for this column in the SelectedItems table
        }
    )
)

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

@BCLS776 

Hi Bryan

 

Thanks but unfortunately I'm still getting an error. I used "stgrp" instead of "aItem"  - I do believe Result is the correct name though. 

Chris110_0-1655831559046.png

 

Let me try to explain this scenario in a different way because I might be leaving something out inadvertently (I'm probably not doing a great job explaining to haha!)

 

In SharePoint I have 2 lists:

  • Fruits and Veggies Mapping Table - helps with dropdown dependencies
  • Ticket List - where users input their data

In the Mapping Table on SharePoint, I have 2 columns - Category and Item

Category (single line of text)Item (single line of text)
FruitApple
FruitBanana
FruitBlackberry
VegetableSpinach
Vegetable

Peppers

 

In the Tickets List on SharePoint, I have the following fields

  • Food Category
    • Dropdown, single-select
    • Values to choose from are Fruit and Vegetable
  • Favorite Food
    • Dropdown, multi-select
    • Values to choose from are Apple, Banana, Blackberry, Spinach, Peppers

 

In PowerApps, I have the following:

  • dd_foodcategory_newitem
    • Dropdown, single select
    • Items property is using Choices() from the Food Category in the Tickets List
  • cmb_favoritefood_newitem
    • Combo box, but herein lies the problem:
    • What should the Items property be?
    • How can I apply a filter based on the mapping table so it's a cascading dropdown based on the selection in dd_foodcategory_newitem?
    • After patching the information to SharePoint...try to imagine a duplicate screen with fields:
      • dd_foodcategory_edititem
      • cmb_favoritefood_edititem
      • How can I...
        • In the combo box, show the selections of the item that was Patched (e.g. user goes to a gallery, selects their item in the list, a variable gets set, etc.)
        • In the Patch code, send the updated data back to SharePoint so the record gets updated (e.g. someone selects Fruit as the category and Apple and Banana as the items in the "newitem" screen then edits their record by removing Banana in the "edititem" screen)

Alright - so - after doing A LOT more research, I found one of @Shanescows videos that got me to the solution.

 

Recall that the problem --> unable to Patch a new record to SharePoint due to combo boxes Items property.

 

Solution --> Using the example I provided (cmb_favoritefood_newitem), here's what I used for the Items property (again - all credit goes to Shane on this!)

RenameColumns(Distinct(Filter('Mapping Table', Category = dd_foodcategory_newitem.Selected.Value),Item), "Result", "Value")

 

So this formula is pulling the Item column from the Mapping Table, but it's only returning based on what's filtered in the Category field. It comes through as "Result" which doesn't play nice with Patch apparently.  Using RenameColumns was INSTRUMENTALLY helpful:

Patch('Tickets List',Defaults('Tickets List'),
{'Food Category': dd_footcategory_newuser.SelectedText},
{'Favorite Food': ForAll(cmb_favoritefood_newuser.SelectedItems, {Value: Value})}
)

 

Thank you again Shane!!!

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,780)