cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BryanSmith
New Member

PowerApps - update text input field with button click

I am having issues updating a text input field when clicking a button. I have read numerous articles that all point to the same setup, but i cannot get it to work.

 

Button Onclick: UpdateContext({varFlag2:"Test"})

Text input Default:  varFlag2

 

I've also tried directly setting the text with the button.

 

Button Onclick: textInput.text = "Test"

Text Input Default: 'Blank'

 

 

When the form is blank and i push the button the field gets updated. But, if i change the data manually in the textinput field and try to click the button again it does nothing. Seems to only work on a blank form. Any suggestions is greatly appreciated.

 

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

You're in the right track. The first option is what you should be using - update a variable to the value that you want the text input to display, and set that variable as the Default property for the text input. The first time you click the button, the variable value will be updated (from nothing to "Test"), so this change is propagated to the text input control. However, if you change the value in the text input, and click the button again, the variable will not change (it was "Test", it will continue being "Test"), so since there were no changes, the control will not be notified.

 

You have a couple of options. You can force a change in the variable by setting it to two different values, which will trigger the control to be notified:

UpdateContext({varFlag2:""}); UpdateContext({varFlag2:"Test"})

Or you can use the Reset function, which will force the control to return to its Default value:

UpdateContext({varFlag2:"Test"}); Reset(TextInput1)

View solution in original post

3 REPLIES 3
CarlosFigueira
Power Apps
Power Apps

You're in the right track. The first option is what you should be using - update a variable to the value that you want the text input to display, and set that variable as the Default property for the text input. The first time you click the button, the variable value will be updated (from nothing to "Test"), so this change is propagated to the text input control. However, if you change the value in the text input, and click the button again, the variable will not change (it was "Test", it will continue being "Test"), so since there were no changes, the control will not be notified.

 

You have a couple of options. You can force a change in the variable by setting it to two different values, which will trigger the control to be notified:

UpdateContext({varFlag2:""}); UpdateContext({varFlag2:"Test"})

Or you can use the Reset function, which will force the control to return to its Default value:

UpdateContext({varFlag2:"Test"}); Reset(TextInput1)

View solution in original post

Thanks for the quick reply.

 

I've been working on this all day and never thought to clear out the variable first. Thanks for your help. Really appriciate it.

Hi @CarlosFigueira,

 

I have a similar problem and I hope its not too late since this was from last year.  

I am trying to update textinput, dropdown and radial controls on 'Screen1', based on a button i click on 'Screen2'.  On screen1 I am inputting data, then i click the 'Add' button, the data is added to a collection, then it transitions to screen2.  On Screen2, I see the rows of data I entered, and each has a checkbox.  If I check a box, there is a modify button, that takes me back to Screen1 which should show the data again on each textinput, dropdown and radial control. 

 

I have tried to do global variable since there are two screens I am working with: Set(varx, "") in the default property of the textinput.  But it seems these properties do not take because these are behavior functions, and default property is non-behavior property.  Hope you can help. Thanks.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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