cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kmamdoh3550
Frequent Visitor

Set text Input text by a button

i am new to powerapps, just a simple question

 

i have a textinput name = test and it is blank

a button with default values

 

i just want to click on that button and set the text for the test textinput to something like " Hello"

 

i tried every function nothing succeeded like :

 

Onselect property for the button

 

test.Text = "Hello"

Set(test.Text,"Hello")

 

 

Please help

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

I found a way to do this...

 

So - what you need to do is:

 

1.  Set the Default property of the TextInput (e.g. TextInput1) to a variable (e.g. VAR_TI1_Def)

2.  On the button click, update the value of the variable and then reset the TextInput like this.

 

UpdateContext({VAR_TI1_Def:"New Text to show in the Text Input field for TextInput1"});Reset(TextInput1)

 

Final:  The Reset() function resets a text input to its default value.  You could potentially update the default value in any number of ways - so this is just one example of how to do what you're asking.  Sorry for the late reply, I've been on sabbatical from Powerapps for over a year. 🙂

View solution in original post

15 REPLIES 15

Yay. This is one that doesn't work the way you (and me) think it should. 

 

What you will need to do is set the Text for your TextInput to a variable. Var1 for example.

 

Then set your button OnSelect to UpdateContext({Var1: "Hello"})

 

Now when you press the button your text will change. 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Sorry as i said i am new 🙂

would you please tell me the steps to set a variable for a text input ?

 

For your label set the Text property to Var1

 

TextVar.PNG

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Hi Shane,  I believe your example above is for a label text box,

can you show us how it's done for a input text box?

cheers!

I found a way to do this...

 

So - what you need to do is:

 

1.  Set the Default property of the TextInput (e.g. TextInput1) to a variable (e.g. VAR_TI1_Def)

2.  On the button click, update the value of the variable and then reset the TextInput like this.

 

UpdateContext({VAR_TI1_Def:"New Text to show in the Text Input field for TextInput1"});Reset(TextInput1)

 

Final:  The Reset() function resets a text input to its default value.  You could potentially update the default value in any number of ways - so this is just one example of how to do what you're asking.  Sorry for the late reply, I've been on sabbatical from Powerapps for over a year. 🙂

This answer doesn't quite work.

 

If you set the label text to the same variable (Var1) as used on the Button, then the text automatically shows the variable's value from the start.  Thus, running the app and clicking the button does nothing as the label text already reads "Hello."  Your screenshot shows as much; notice how the label Text is set to Var1 at the top but in the screen of the app below, the default text in the label already shows "Hello."

 

I'm very new to PowerApps so I don't know the correct answer, but I suspect that the text for the label must first be set to a blank or empty variable value so that the button can change it to "Hello" when pressed.

@OmegaWulf  psssst....  you're looking at the wrong solution.   🙂    Look for my post up above, and good luck.

Anonym2
Frequent Visitor

You need to set a variable in the button like this. set(value, "hello"); and then in the textbox default field you need to set this, value variable.

@Anonym2 @Kmamdoh3550 @NEPatton @OmegaWulf @brandonkim83 

 

I'm using your post to help me configure my sharepoint form. 

 

I have a button with 'OnSelect' of UpdateContext({varNoteText:varNoteText & User().FullName & " " & Now() & ": " & RichTextComments.Text & Char(13)}); Reset(DataCardValue36) which is partially working, but it doesn't update the sharepoint record with the information in varNoteText, what am i missing?

 

When i open the sharepoint form (powerapp form) i want the default value to be from the sharepoint record, but then the button to add text to the sharepoint record with text that a user has inputted into a custom text field

 

stujol80_0-1599161979578.png

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

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