Forum Discussion
How to Update a Field through a button's OnSelect Event
I should mention that if you want to use the variable as the value of an input field you can set the Default property of the field to the variable.
Do I set the Default property of the target field (Status) to the variable in runtime programmatically or do I do it in advance as a formula?
If it’s it advance, then I think I need to capture the field value and put it in the variable on load, so that the field can be populated with that value; then have my button change the variable to the new value (e.g. “Complete”); then the field will reflect the updated value. Is this correct?
- Peter McDonaldDec 11, 2017Copper Contributor
You set it in the formula for the field Default.
Yes that can work, or you can use an if statement in the formula, if it is on the input field (not the card) it could be if( IsBlank(VariableX), ThisItem.Default, VariableX) that what the default value of the card is the original data from the database and the field gets a different default value based on if the variable has data or not.
- DeletedDec 11, 2017
Hey Peter,
That is throwing an error. I tried both ThisItem.Default and Parent.Default, but the real error seems to be the variable isn't of the type expected. I have set it as a Text variable. I also noticed that the values available to the dropdown (Not Started, Started, and Complete) don't show up either with this.
- Peter McDonaldDec 11, 2017Copper Contributor
I would need to build a sharepoint list and powerapp to test this, but what I would try is setting the value of the variable to the actual record that the dropdown in looking for, e.g.
Set(varStatus, Lookup(Status, Value = "Started"))
Let me know if trying something like this works and if not I will run up a test app for you.
- DeletedDec 11, 2017Very helpful Peter. It’s late in my time zone. Will try when I get to work.