Search code examples
sharepoint-onlinepowerappssharepoint-listpowerapps-collection

in powerapps how do I get a collection of the selected values of a multiselect from a sharepoint list WITHOUT using a combobox


I have a sharepoint list that has a multiselect column. in powerapps I would like to make a collection of the selected values.

for example I have a multiselect column named category that have choices One, Two, Three, and Four. I have selected Two and Four.

my code in powerapps Integrated Form OnEdit is

Clear(myCollection); 
ForAll(Choices([@SMEList].Category), Collect(myCollection,ThisRecord.Value));

but that is giving me One, Two, Three and Four. I only want the selected Values (Two and Four)


Solution

  • This works:

    ClearCollect(colMyCollection,
        Filter(
            Choices('2022-05-23_StackOverflow'.SMEList),
            Or(
                ThisRecord.Value = "Choice 2",
                ThisRecord.Value = "Choice 4"
            )
        )
    )
    

    Illustrated:

    enter image description here


    EDIT 1

    • Ok. I changed the SP column to multiselect.
    • OnStart of the app, ClearCollect(colList, <SP_list_name>)
    • Insert a Gallery control, set its Items property to colList. Set its OnSelect property to Set(varRecord, ThisItem)
    • Insert a Form control, set its Item property to LookUp(colList, ID = varRecord.ID)

    Illustrated

    enter image description here


    EDIT 2

    RE: ...just get it from the sharepoint list .

    • Leave the OnStart function to ClearCollect(colList, SharepointList)
    • Gallery:
      • Leave the GalleryItems property to colList
      • Change the TextBox (in the Gallery) Text property to Concat(ThisItem.SMEList, Value, ",")
    • Form:
      • You already have the values from the Sharepoint list in the ComboBox. Its unclear to me why you to manipulate these values outside of the ComboBox.
      • How about just changing the DisplayMode property of the ComboBox to View.
      • Then its read-only

    enter image description here