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

OnSelect not firing on certain screen

I have a screen where no OnSelect events will fire, though the Powerapps studio, web or mobile.  

 

It is a simple statement CalMonthCurrentDate.Text = "1", Originally it was CalMonthCurrentDate.Text = Text(DateValue(StartDate)+6, ShortDate).  I shorted it to eliminate variables.

 

I've wired many different controls with this statement and none of them work.  If I put a Navigate instead, that works fine. 

 

Any suggestions?  Is there any advanced way to debug these?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps
Power Apps

 

I am trying to understand what you are hoping to do in that OnSelect property. You mentioned a "statement" "CalMonthCurentDate.Text = 1 " -- are you trying to force a value into a property of a control, imperatively? (i.e. "set" the property?)

 

If that is what you are trying to do, PowerApps does not work that way. The "=" operator is an equality operator, not an assignment operator. Unlike imperative languages like JS, C++, Java, C#, etc. where you tell objects what to do, PowerApps's expression language is a declarative dataflow language, in which you declare what data flows into each property, and how it needs to be transformed on its way into the property. This is very similar to how Excel formulas work: you declare how each cell's value needs to be computed; and the dataflow engine does the rest of the work, iteratively flowing data where it needs to go, and evaluating all affected formulas to a steady state.

 

If the goal is to set the Text property of CalMonthCurrentDate to "1", you will need to declare that value ("1") as the default value flowing into the control. For example for a Textbox control, bind its Text property to "1". For a TextInput control, bind its Default property to "1". If you are dealing with a stateful control, such as a TextInput control, and you want to "reset it" to some value such as "1" from an OnSelect property of another control, you need to pulse the Default property from that formula:

 

    TextInput1.Default = DefaultValue

    Button123.OnSelect = UpdateContext({DefaultValue: ""}); UpdateContext({DefaultValue: "1"})

 

Please see the formula reference for more information.

https://powerapps.microsoft.com/en-us/tutorials/formula-reference/

 

I hope this helps.

 

 

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

3 REPLIES 3
Community Champion
Community Champion

Perhaps it is that DateValue only works on Text. You can try reversing the order that you have it:

DateValue(Text(StartDate,"mm/dd/yyyy"))
Microsoft Employee
@8bitclassroom
Power Apps
Power Apps

 

I am trying to understand what you are hoping to do in that OnSelect property. You mentioned a "statement" "CalMonthCurentDate.Text = 1 " -- are you trying to force a value into a property of a control, imperatively? (i.e. "set" the property?)

 

If that is what you are trying to do, PowerApps does not work that way. The "=" operator is an equality operator, not an assignment operator. Unlike imperative languages like JS, C++, Java, C#, etc. where you tell objects what to do, PowerApps's expression language is a declarative dataflow language, in which you declare what data flows into each property, and how it needs to be transformed on its way into the property. This is very similar to how Excel formulas work: you declare how each cell's value needs to be computed; and the dataflow engine does the rest of the work, iteratively flowing data where it needs to go, and evaluating all affected formulas to a steady state.

 

If the goal is to set the Text property of CalMonthCurrentDate to "1", you will need to declare that value ("1") as the default value flowing into the control. For example for a Textbox control, bind its Text property to "1". For a TextInput control, bind its Default property to "1". If you are dealing with a stateful control, such as a TextInput control, and you want to "reset it" to some value such as "1" from an OnSelect property of another control, you need to pulse the Default property from that formula:

 

    TextInput1.Default = DefaultValue

    Button123.OnSelect = UpdateContext({DefaultValue: ""}); UpdateContext({DefaultValue: "1"})

 

Please see the formula reference for more information.

https://powerapps.microsoft.com/en-us/tutorials/formula-reference/

 

I hope this helps.

 

 

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

I did not realize that, with your suggestion it now works perfectly.

 

Thanks

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (20,161)