SOLVED

How to update a data card field value from an action

MVP

I have been playing around with PowerApps a bit more with the SharePoint integration.  It's fairly straight forward to update a regular text field from a button by setting the default value of the text input field using UpdateContext. However, it doesn't seem to be that easy with a data card value because the text field (while editable) is pulling it's data from the list item.  How can I update the text field component of the data card from a button so that when the form is updated it sends the new data to the list item as if I typed it myself.

 

For example, say I have a button called "Blank The Field".  I have a data card that points to a list item called Notes.  When I edit the form I can delete any text from the Notes field and update the list item by saving.  What I want to do is have "Blank The Field" do that for me.  Is this possible from a button?  Is it similar to a regular text box and I am just missing something?

 

Thanks in advance.

1 Reply
best response confirmed by David Drever (MVP)
Solution

So after some testing, I found that you have to set the data card value to a context value. But you have to be careful because the context value should be set when the form is visible from the source or else you run the risk of accidentally setting bad data. So basically it goes like this:
- set Data Card Value default property to a contextValue
- Set the contextValue to the source of that field on screen visible
- in your button call UpdateContext and set the contextValue to whatever you want

This sets the value. I'll be blogging it with a bit more information shortly. Stay tuned.

1 best response

Accepted Solutions
best response confirmed by David Drever (MVP)
Solution

So after some testing, I found that you have to set the data card value to a context value. But you have to be careful because the context value should be set when the form is visible from the source or else you run the risk of accidentally setting bad data. So basically it goes like this:
- set Data Card Value default property to a contextValue
- Set the contextValue to the source of that field on screen visible
- in your button call UpdateContext and set the contextValue to whatever you want

This sets the value. I'll be blogging it with a bit more information shortly. Stay tuned.

View solution in original post