cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Humanity
Helper V
Helper V

How to use a dropdown in a component to control a variable

We have a dropdown in a component menu, that lists the name of buildings a user may choose from.  When a person chooses one it is to change the app BUILDING variable.

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Humanity ,

Do you want to use a drop down inside a component to change a global variable?

That means: you need to use control inside component to trigger an action.

However, the point is: it's not supported to customize behavior property of component.

The solution is to use toggle to trigger the action of setting variable.

However, toggle's value could only be true or false. So you could use toggle to do this only when you want BUILDING variable has two value, more is not supported.

I've made a similar test for your reference:

 

1)drop down inside the componnet:

Items:

[1,2,3,4]

2)create a custom output variable of the component like this:

7201.PNG

 set the component's varvalue:

Dropdown2.Selected.Value

 

2)outside the component, inside the app

insert this component and insert a toggle

set the toggle's Default:

If(Component1_1.varvalue=1||Component1_1.varvalue=2,true,false)

set the toggle's OnCheck:

Set(BUILDING,"value1")

 set the toggle's OnUncheck:

Set(BUILDING,"value2")

set the toggle's Visible:

false

 

Then if you choose 1or2 in that drop down, the toggle will be true and you will set BUILDING to value1.

If you choose 3or4 in that drop down, the toggle will be true and you will set BUILDING to value2.

 

What's more, if you want to set BUILDING to more than two values, I suggest you put that drop down outside the component.

Except using toggle, I'm afraid there's no better way to use control inside component to trigger action.

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
yashag2255
Dual Super User II
Dual Super User II

Hi @Humanity 

 

Can you try to update the OnChange property of the dropdown control to:

Set(BUILDING, DropdownName.Selected.ColumnName)

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

v-yutliu-msft
Community Support
Community Support

Hi @Humanity ,

Do you want to use a drop down inside a component to change a global variable?

That means: you need to use control inside component to trigger an action.

However, the point is: it's not supported to customize behavior property of component.

The solution is to use toggle to trigger the action of setting variable.

However, toggle's value could only be true or false. So you could use toggle to do this only when you want BUILDING variable has two value, more is not supported.

I've made a similar test for your reference:

 

1)drop down inside the componnet:

Items:

[1,2,3,4]

2)create a custom output variable of the component like this:

7201.PNG

 set the component's varvalue:

Dropdown2.Selected.Value

 

2)outside the component, inside the app

insert this component and insert a toggle

set the toggle's Default:

If(Component1_1.varvalue=1||Component1_1.varvalue=2,true,false)

set the toggle's OnCheck:

Set(BUILDING,"value1")

 set the toggle's OnUncheck:

Set(BUILDING,"value2")

set the toggle's Visible:

false

 

Then if you choose 1or2 in that drop down, the toggle will be true and you will set BUILDING to value1.

If you choose 3or4 in that drop down, the toggle will be true and you will set BUILDING to value2.

 

What's more, if you want to set BUILDING to more than two values, I suggest you put that drop down outside the component.

Except using toggle, I'm afraid there's no better way to use control inside component to trigger action.

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

I believe I understand everything except this part:

 

 set the component's varvalue:

Dropdown2.Selected.Value
TedBabcock
Helper I
Helper I

An update: there is a new experimental feature to allow behavior events to fire from components in the hosting app. Previously only OnReset was supported. Info is here:

https://powerapps.microsoft.com/en-us/blog/enhanced-component-properties/

Creating a component custom property called Selected, defined as an Output property of type Record, and set to Dropdown.Selected within the component allows the dropdown's Selected property to be accessed in the hosting app.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (55,239)