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", "")
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityAdd 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}
A few things you should notice:
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.
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.