Hi all,
I am trying to set a value on a field when the form is submitted.
In the onSelect of a button I have:
DataCardValue28.Text="Yes";SubmitForm(FormBewerkGebruiker)
Unfortunate that isn’t working. The field is not updated.
The idea is that this value must always be set when a user submits a form so that is why a put this code to update the field in the same button. Is setting DataCardValue a wrong idea here? Or is there maybe a better solution, so I am open for ideas.
Solved! Go to Solution.
Hi @AGroegelich
You are almost there
If(
DataCardValue28.Text="Yes";
SubmitForm(FormBewerkGebruiker)
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi Warren,
That only submits the form when DataCardValue28.Text="Yes". But that is not what I meant.
What I would like to happen is that the field in DataCardValue28is automatically updated to "Yes" when a form is submitted. The field itsself is hidden and must not be touched by the user.
The code DataCardValue28.Text="Yes" doesn't do the trick.
Hi @AGroegelich ,
Set the Default of DataCardValue28.Text to vUpdate (you can use whatever name you want for the Variable)
On the submit form do this
SubmitForm(FormBewerkGebruiker);
UpdateContext({vUpdate:"Yes"});
Reset(DataCard28)
I have used semi colons ; for new line commands (I believe you use something else ) as you use these where we use commas.
What you are doing is resetting the control when submitting, which will then take its default value, which you have set in the submit code
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @PowerAddict,
Thank you, that might work.
However my problem might be a bit more complex then I have told yet. I noticed the SubmitForm only save to the data source when something is changed in the form. So if the user clicks the OK button but there wasn’t changed anything (only the screen is closed).
So what I want to achieve is only to change the value of my field (in fact is called “Updated”) when something is modified in the form. Is that even possible?
But that is also the reason why I trying to update the field in the onSelect of the OK button.
Hi @WarrenBelz,
Thank you, that also works. That gives a new challange. Is somehow to to fill this Context variable with "ThisItem.Myfield" when opening the form?
Hi @AGroegelich ,
On the OnVisible property of the screen
UpdateContext({vUpdate:ThisItem.MyField})
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @WarrenBelz,
Unfortunate there is no onVisible on the EditForm in my version of PowerApps, only in the properties of the screen. Am I missing something?
Hi @AGroegelich ,
It is the screen (see post).
I made a typo and corrected it about 10 seconds later. You must have been too quick.
User | Count |
---|---|
253 | |
113 | |
92 | |
48 | |
38 |