Set sharepoint datasource textbox value with button?

%3CLINGO-SUB%20id%3D%22lingo-sub-377982%22%20slang%3D%22en-US%22%3ESet%20sharepoint%20datasource%20textbox%20value%20with%20button%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-377982%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20screen%20with%20a%20form%20based%20on%20a%20Sharepoint%20list%20datasource.%3C%2FP%3E%3CP%3EI%20have%20one%20column%20in%20my%20sharepoint%20list%20that%20is%20a%20text(string).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETho%20i%20do%20not%20want%20to%20have%20the%20user%20manually%20edit%20this%20specific%20column.%3C%2FP%3E%3CP%3EI%20want%20to%20add%20two%20buttons.%3C%2FP%3E%3CP%3EIf%20user%20press%20button%201%20the%20value%20of%20the%20column%20textbox%20is%20set%20to%20YES%20and%20if%20user%20press%20button%202%20the%20value%20is%20set%20to%20NO%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20option%20that%20i%20could%20accept%20as%20a%20solution%20is%20to%20somehow%20change%20the%20textbox%20in%20the%20form%20in%20powerapps%20to%20a%20dropdown%20so%20that%20the%20user%20can%20pick%20between%20two%20values.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20use%20a%20toggle%20control%20to%20swich%20between%20yes%20and%20no.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20my%20problem%20is%20that%20i%20need%20the%20column%20in%20my%20sharepoint%20list%20to%20be%20a%20Text%20column%20and%20not%20an%20%22option%22%20or%20%22yes%2Fno%22%20column.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyone%20able%20to%20help%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-377982%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerApps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-481753%22%20slang%3D%22en-US%22%3ERe%3A%20Set%20sharepoint%20datasource%20textbox%20value%20with%20button%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-481753%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F89819%22%20target%3D%22_blank%22%3E%40Oskar%20Kuus%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20simplest%20way%20is%20to%20use%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowerapps%2Fmaker%2Fcanvas-apps%2Fworking-with-variables%23use-a-context-variable%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EContext%20Variable.%3C%2FA%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EI%20created%20a%20basic%20list%2C%20and%20just%20kept%20the%20TITLE%20field.%26nbsp%3B%3C%2FLI%3E%3CLI%3EI%20added%20the%20form%20for%20that%20list's%20datasource%20onto%20the%20screen.%3CUL%3E%3CLI%3EIn%20this%20example%2C%20I%20put%20my%20form%20in%20NEW%20mode.%20I'm%20assuming%20you're%20adding%20new%20records.%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3EI%20added%20a%20YES%20and%20a%20NO%20button.%3C%2FLI%3E%3CLI%3EFor%20both%20buttons%2C%20I'm%20using%20the%20same%20UpdateContext%20function%20in%20their%20OnSelect%20properties.%20See%20the%20screen%20below.%20UpdateContext%20sets%20the%20value%20of%20Context%20Variables%2C%20which%20are%20variables%20usable%20on%20the%20same%20screen%20only.%26nbsp%3B%3C%2FLI%3E%3CLI%3EIn%20my%20case%20I%20created%20a%20Context%20Variable%20called%20%22userAnswer.%22%3C%2FLI%3E%3CLI%3EThe%20Yes%20button%20sets%20it%20to%20%22Yes%22%20and%20the%20No%20button%20sets%20it%20to%20%22No.%22%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20798px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F110102iE3A26441AC8D9831%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pa-form.PNG%22%20title%3D%22pa-form.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3ENext%2C%20you%20will%20need%20to%20modify%20the%20field%20you%20want%20to%20work%20with.%20But%20because%20it's%20in%20the%20form%2C%20properties%20will%20be%20locked.%26nbsp%3B%3C%2FLI%3E%3CLI%3EClick%20on%20the%20field%2C%20then%20click%20on%20the%20Advanced%20tab%20in%20the%20right%20panel%20and%20select%20%22Unlock%20to%20change%20properties.%22%3C%2FLI%3E%3CLI%3ETo%20make%20this%20work%2C%20you%20need%20to%20bind%20your%20text%20field's%20value%20to%20the%20Context%20Variable%20you%20created%20previously%20(the%20one%20being%20changed%20by%20the%20Yes%20and%20No%20buttons).%3C%2FLI%3E%3CLI%3EYou%20do%20this%20by%20setting%20the%20field's%20Default%20property%20to%20the%20variable.%20See%20below.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20641px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F110103iA4C5A9F1B6E5083B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22field-default.PNG%22%20title%3D%22field-default.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20when%20you%20click%20each%20button%2C%20the%20text%20box's%20value%20will%20change.%20One%20other%20touch%3A%20you%20might%20want%20to%20change%20the%20text%20box's%20DisplayMode%20property%20to%20%22Disabled%22%20so%20users%20cannot%20enter%20values%20directly%20into%20it.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps!%20Let%20me%20know%20how%20it%20works%20out!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Frequent Contributor

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?

1 Reply
Highlighted

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."

 

pa-form.PNG

 

  • 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.

 

field-default.PNG

 

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!