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 III
Super User III

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 III
Super User III

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

@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

View solution in original post

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,803)