Forum Discussion

Oskar Kuus's avatar
Oskar Kuus
Iron Contributor
Mar 20, 2019

Set sharepoint datasource textbox value with button?

I have a screen with a form based on a Sharepoint list datasource.

I have one column in my sharepoint list that is a text(string).

 

Tho i do not want to have the user manually edit this specific column.

I want to add two buttons.

If user press button 1 the value of the column textbox is set to YES and if user press button 2 the value is set to NO

 

Another option that i could accept as a solution is to somehow change the textbox in the form in powerapps to a dropdown so that the user can pick between two values.

 

Or use a toggle control to swich between yes and no.

 

But my problem is that i need the column in my sharepoint list to be a Text column and not an "option" or "yes/no" column.

 

Anyone able to help?

  • Tom_Santos's avatar
    Tom_Santos
    Copper Contributor

    Hi Oskar Kuus,

     

    The simplest way is to use a Context Variable.  

    • I created a basic list, and just kept the TITLE field. 
    • I added the form for that list's datasource onto the screen.
      • In this example, I put my form in NEW mode. I'm assuming you're adding new records.
    • I added a YES and a NO button.
    • For both buttons, I'm using the same UpdateContext function in their OnSelect properties. See the screen below. UpdateContext sets the value of Context Variables, which are variables usable on the same screen only. 
    • In my case I created a Context Variable called "userAnswer."
    • The Yes button sets it to "Yes" and the No button sets it to "No."

     

     

    • Next, you will need to modify the field you want to work with. But because it's in the form, properties will be locked. 
    • Click on the field, then click on the Advanced tab in the right panel and select "Unlock to change properties."
    • To make this work, you need to bind your text field's value to the Context Variable you created previously (the one being changed by the Yes and No buttons).
    • You do this by setting the field's Default property to the variable. See below.

     

     

    Now when you click each button, the text box's value will change. One other touch: you might want to change the text box's DisplayMode property to "Disabled" so users cannot enter values directly into it. 

     

    Hope this helps! Let me know how it works out!