web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Set value for on a fie...
Power Apps
Unanswered

Set value for on a field when submitting a form

(0) ShareShare
ReportReport
Posted on by 140

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.

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    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

  • AGroegelich Profile Picture
    140 on at

    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.

     

     

  • Verified answer
    PowerAddict Profile Picture
    7,316 Most Valuable Professional on at
    Hi @AGroegelich,

    Just set the Default property of that datacard (Which I believe is a textinput control) to "Yes". This way that data card will always have the value Yes and that is the value that will be submitted.

    If you dont want the user to see this, you can set the visible property of the datacard to No.

    Let me know if this helps.

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

    Thanks!
    Hardit Bhatia
    https://thepoweraddict.com
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    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.

  • AGroegelich Profile Picture
    140 on at

     

    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.

  • AGroegelich Profile Picture
    140 on at

    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?

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    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.

  • AGroegelich Profile Picture
    140 on at

    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?

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    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.

  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at
    You could simply use a Patch function on the OnSelect. If nothing else was changed, those values will stay as they are. And you can update the concerned field with a value = Yes.

    Let me know if this approach sounds viable and we can get into the details.

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

    Thanks!
    Hardit Bhatia
    https://thepoweraddict.com

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard