cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mats_1997
Helper I
Helper I

Updating a variable

Hi

 

In my app I have a drop down with a list of values 1-20. the drop down's on change is Set(y,<nameOfDropDown>.SelectedText), which is fine. The thing is that when I go to that screen, y is not yet set, so y has a 0 value, which is not good for the rest of what's going on in the screen.

I tried setting the default value of the box to 1, but I get why that doesn't work, which leads to my issue. I tried to set the screens OnVisible to be Set(y, 1) kinda like you would do with a variable in any other programing language. The dropdown box declaration y was however not so happy with that, causing a whole string of errors with multiple declarations...

My question then is. how do I make a variable with an initial value, and then change it to later to be what you select in the dropdown box?

btw, I have tried using UpdateContext too to keep it local, which would be best practice, buut, it didn't change anything.

2 ACCEPTED SOLUTIONS

Accepted Solutions
eka24
Super User
Super User

With Set(y,<nameOfDropDown>.SelectedText), Can you give the Items formula of the Dropdown. That will determine what will go into the variable.

However, try OnVisible of the screen: Set(y,nameOfDropDown.Selected.Value

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

View solution in original post

Mats_1997
Helper I
Helper I

I have no idea why, suddenly it just worked, with the screens onSelect being Set(y,1) and the dropDown Onchange being Set(y, MyDropDown.Selected.Value) almost as @eka24  suggested, no idea why it suddenly worked, because it didn't work the first time I tried it

View solution in original post

7 REPLIES 7
eka24
Super User
Super User

With Set(y,<nameOfDropDown>.SelectedText), Can you give the Items formula of the Dropdown. That will determine what will go into the variable.

However, try OnVisible of the screen: Set(y,nameOfDropDown.Selected.Value

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

@eka24 

That solves the initializing problem, but I could just as well have used Set(y, 1), it does not make the y value change when you change the value of the drop down 😕

I'd like something similar to
screen OnVisible: Set(y, 1)
dropdown Onchange: Update(y, dropdown.SelectedText)

Please show the items of the dropdown to help solve the issue

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 12345.PNG
Like I said in my OP, I filed it with an array of int 1-20 ^^. The issue is that, yes, I can initialize a value in the screens OnVisible function like this: Set(y, dropdown.Selected.value), which will initially set it to 1 as is desired, but, it won't dynamically change the value in the dropdown. I also can't use go to the dropdowns onChange function and write Set(y, dropdown.selected.value) to dynamically uppdate y...

So I wonder how can I initialize a varable AND dynamically uppdate it as changes are made to the dropdown 

You can set a variable OnChange of the Dropdown:

Set(YY,Dropdown2.SelectedText.Value)
------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

@eka24 

 

I'm sorry, I think I'm not explaining properly
I have a variable y, that needs to start as 1, but change to be something else when I change the drop down. the variable value needs to change from when it is initialized

Mats_1997
Helper I
Helper I

I have no idea why, suddenly it just worked, with the screens onSelect being Set(y,1) and the dropDown Onchange being Set(y, MyDropDown.Selected.Value) almost as @eka24  suggested, no idea why it suddenly worked, because it didn't work the first time I tried it

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,332)