1

I am customizing the SharePoint list form using PowerApps. I have a requirement to change the selected value of the combo box control on the click event of another button.

Actually I tried multiple ways as below to change the selected value in combo box from On click of button. but no success.

Tried ways are as below:

[{Value:"option1"}]

["option1"]

Please help me on this.

2 Answers 2

0

Try this solution:

Set the following formula to OnSelect property of button:

Set(defaultComboValue, LookUp(Choices('SP List'.ChoiceColumnName), Value="option1"))

Set the following formula to DefaultSelectedItems of combo box:

If(IsBlankOrError(defaultComboValue), Parent.Default, defaultComboValue)

References:

  1. Change the value of a dropdown by clicking a button
  2. How To set the selected value of a combo box to one of the choices using PowerApps
1
  • Thanks for the reply, Actually I am already following the second link you have mentioned. The approach it mentions it actually changes the combo box selected value, which works fine. Post updating on button click if I try to save the form means I am doing SubmitForm(Form1), it is throwing error as the mentioned combo box contains invalid value. May 6, 2021 at 11:49
0

Ok - I'm deriving my answer from the answer given by Ganesh Sanap - his second link had what I needed.

My goal was to use a vertical gallery to select an item in a different list than the combo box's data source. The ID of the item selected in the gallery would then be used to select the item in the combo box. It's important to note that these items were related through a list lookup in SharePoint. This allowed me to display additional information in the gallery and then hide the combo box from the user.

Basic Elements Involved:

  • Vertical gallery (selected_kit_gallery)
    • This is based on my 'Kit Status' list
  • Combo box (name doesn't matter)
  • Variable to hold gallery selection (kitvar)
  • Gallery settings to assign the selected item to the variable (OnSelect)
  • Combo box settings to select the item that is stored in the variable from the gallery (DefaultSelectedItems)
    • This is based on my 'Kit Requests' lists

Overview

  1. Build your canvas form - the gallery in this example is called selected_kit_gallery

  2. Select the "Tree View" (3 stacked squares) in the left hand pane and select "App" Tree View for App

  3. Find the OnStart property under "Advanced" in the right hand pane to create a variable that will store the selected item from the gallery.

    • You have to point the variable at the gallery when it's created in order for it to assume the correct object type.

      • Don't worry about the rest of my variables, just kitvar :)
    • Example: Set(kitvar,selected_kit_gallery.Selected)

    • Set variable in OnStart using the selected item from the gallery

  4. Now, find your gallery and click on the "Select" arrow

    • Select Arrow for Gallery
    • Next find the OnSelect property and make it change the variable to the gallery's selected item
    • Example: Set(kitvar,selected_kit_gallery.Selected)
    • Gallery OnSelect action
  5. Now find your combo box data card and click on the combo box itself:

    • Combo Box Selected Directly
    • Find the combo box's DefaultSelectedItems under the "Advanced" tab in the right hand pane
      • Set this so that it will reference the kitvar variable and allow the combo box to follow whatever is selected in the gallery
    • Example: Filter(Choices('Kit Requests'.assigned_kit),Id=kitvar.ID)
    • Combo Box DefaultSelectedItems

I've actually tweaked a lot more in the gallery so that it's obvious to the user once a kit has been selected. This took me a lot longer to figure out than it should have! Hope it helps someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.