1

How to, using image as button to set a value of a field OnSelect. I have a PowerApp associated with a SharePoint list access through Edit Form in list from SharePoint Online. I have an image I would like to use as a button. When said button is clicked I want to set a value in the list to update the list value.

1

PowerApps lacks the ability to directly set the value of a field via an event. Instead, it has a more excel-like mechanism:

Set the value of your field to be a variable, such as varMyVariable. To clarify, what I mean by saying "the value of your field" can be a bit tricky, depending on how your form is configured, but the common scenario would be the default property of the datacard:

myField_datacard5.default = varMyVariable

In the onselect event of the button, use the "set" function to set the value of the variable as desired:

button1.OnSelect=Set(varMyVariable,"some value")

Of course, there are few things in PowerApps that are actually simple. the default will likely be the following:

thisitem.myfield

You'll need to unlock the card to change this. And, if you actually set it to what I suggested, then this will cause issues for updating rows, as the card won't display the existing value, but instead will show the current value of the variable. So perhaps in the screen's onvisible event, or the app's onstart event, call the set function to initialize the variable with the appropriate value so the card displays something other than a blank value. Or, an alternative is to display the value of the field if the variable is currently blank:

myField_datacard5.default = if(isblank(varMyVariable),thisitem.myfield,varMyVariable)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.