1

I need to set up a dropdown selection based on a button trigger. If button not selected, dropdown must remain empty.

Could anyone assist?

Using following syntax on the dropdown:

If(button1.selected, dropdown1= "selection", "")

2 Answers 2

1

Add this formula on OnVisible property of Screen:

UpdateContext({ddDefaultValue: ""})

Then set Default property of dropdown control to:

ddDefaultValue

Add below formula on OnSelect property of button:

UpdateContext({ddDefaultValue: "selection"})

For more information, refer: Set Dropdown value with Button Click


Update:

Note that, if you are using a combo box control, trying to use only a variable, whether in Default or DefaultSelectedItems, will give you an error:

There is an error in this formula. Try revising this formula and running it again.

In that case, you would have to set it in this way:

{Value: ddDefaultValue}
6
  • Can't just set the Default (or DefaultSelectedItems) property of the dropdown to a variable - it will give you an error: "There is an error in this formula. Try revising this formula and running it again." The link has this as something the OP already tried and failed at, not the solution.
    – vapcguy
    May 31 at 15:56
  • I have tested it and it worked fine for me. It worked for OP as well and already marked as an answer. Which "link" are you talking about exactly? Maybe there is something wrong with how you set the variable and the data type of variable. Ask new question specific to your requirements mentioning those in details instead of downvoting working & accepted solutions. May 31 at 16:30
  • 1
    @vapcguy Also, I think you are using combo box control and not the drop down control. As, DefaultSelectedItems property is not available for drop down control. Hence the structure and data type variable needs to be in different format for both the controls. May 31 at 17:22
  • 1
    I have approved your edits now. Jun 1 at 4:40
  • 1
    Thanks, removed my downvote.
    – vapcguy
    Jun 1 at 17:28
1

A few things you should notice:

  1. There is no Selected property for Button control.

    As far as I know, you can only configure one-way action on one button control, there is no “release” or “unselect” status for it once the button is clicked, unless you reset Button.OnSelect from outside.

    You will need a second button if you want to clear the dropdown control value.

  2. If you decide to use UpdateContext function (as the first Answer introduced), note that the default value should be set on the Choice column data card instead of the combo box (DataCardValue2)

    For example:

    <ChoiceColumn>_DataCard.DefaultSelectedItems = { Value: ddDefaultValue }

And you could update ddDefaultValue in the OnSelect of a button:

Set(ddDefaultValue,"My Dropdown Value")

In the App's OnStart:

Set(ddDefaultValue,"")

So it remains empty unless the button is clicked.

Your Answer

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

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