Sorry for asking an incredible simple question (I think). Not sure why this baffles me.
I have tried to test event-driven logic as follows, and I have not gotten it to work.
1. Create input text box Input_Text
2. Create input text box Output_Text
3. Create button Push.
4. For Push Button, on select, output_text.text=input_text.text
What's wrong with this?
Solved! Go to Solution.
yes, that's the only way I've ever gotten these kinds of changes to work for me.
Hi @akharns
Couple of ways to do this:
#1
#2
Thanks.
What's wrong is that PowerApps is at its heart a declarative system not a procedural language. So you can't have an event like a button press change a property of another object like a Text box directly. The way to do this in Powerapps is to set the default text for output = to a variable value and then set the variable value equal to the other textbox when you press the button. That way none of the object properties on the screen are driectly altered by the actions of another object.
I was really doing this only to debug the event firing feature. I want to change attributes of Galleries and Forms (visible & size) based on actions taken in other controls (combo boxes or galleries). I thought my little experiment would verify the functioning of these events, so I could troubleshoot the actions that were to be tied to them.
I think I hear you say that I need to create variables to control these cross-control actions.
For most of them yes. I don't think I've found any properties that can be modified directly at runtime.
This discussion seems to conflict with the following :
Understand canvas-app variables in PowerApps
If you've used another programming tool, such as Visual Basic or JavaScript, you may be asking: Where are the variables? PowerApps is a little different and requires a different approach. Instead of reaching for a variable when you build a canvas app, ask yourself: What would I do in Excel?
In other tools, you may have explicitly performed a calculation and stored the result in a variable. However, PowerApps and Excel both automatically recalculate formulas as the input data changes, so you usually don't need to create and update variables. By taking this approach whenever possible, you can more easily create, understand, and maintain your app.
That post is true as far as it goes. Variables are much less prevalent in PowerApps. But the anology breaks down because Excel doesn't have objects with properties like PowerApps. In terms of formulas and calculations its true. Values don't have to be stored in Variables. They can be embedded right into the function. The problem is this makes a lot of the functions almost unreadably long, so I often still use variables to summarize values for readability. But in this case its esssential, because that's the only way to actually get these properties to change at runtime.
I have it working now. Here is my solution:
1. Text box TestDisplay, property Text: TestString - This reads the context variable TestString
2. Text box TestInput, event On Change: UpdateContext({TestString:TestInput}) - This updates the context variable TestString
I'll wait for final feedback before closing this. Thanks, everybody, for your help.
yes, that's the only way I've ever gotten these kinds of changes to work for me.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
201 | |
176 | |
62 | |
32 | |
30 |
User | Count |
---|---|
314 | |
264 | |
104 | |
76 | |
56 |