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 / Field not updated OnSe...
Power Apps
Answered

Field not updated OnSelect of submit form button - uses Default value instead

(0) ShareShare
ReportReport
Posted on by 106

Hello,

 

We have a PowerApps form which connects to a SQL Server database.  We want to capture the current user and the time the user clicks the submit button to save the record.  But, the date/time logic is not working.  It does not update the date stamp to time of the submit - it uses the default value for the field instead.  We also set these values in the Default values of these fields.  Should these default values be removed so it only sets them on the Submit click?

 

DataCardValue1.Text=User().Email;
DateValue5.SelectedDate = Today();
HourValue1.Selected.Value = Text(Hour(Now()),"[$-en-US]00");
MinuteValue1.Selected.Value = Text(Minute(Now()),"[$-en-US]00");
SubmitForm(EditForm_InvestmentChecklist)

 

Thanks,
Dan

Categories:
I have the same question (0)
  • Verified answer
    Mr-Dang-MSFT Profile Picture
    on at

    Hi @lesotho_kid ,

    It looks like you are using Now() in a form's Default properties, but they are not updating in a way you expect.

     

    The Now() and Today() functions are volatile, meaning they can change each time they are called. But when used in a property, a new value is not continuously returned. Think of it as the value for Now() was only retrieved when first setting the property.

    Docs: https://docs.microsoft.com/powerapps/maker/canvas-apps/functions/function-now-today-istoday#volatile-functions

     

    For scenarios where you want to save the time now, you may consider retrieving a date time ahead of submission and set it to a variable. For example, you could use logic like this:

    Set(varTimeNow,Now());
    SubmitForm(EditForm1)

     

    This means, "Set a variable called varTimeNow to the current time. Then submit the form."

    In your card for the time, you could set each to Default to calculations against varTimeNow instead. The form will acknowledge the new value for the time from the variable and the form is submitted.

     

    Let me know if this helps.

  • v-xida-msft Profile Picture
    on at

    Hi @lesotho_kid ,

    Regarding the issue that you mentioned, I think this issue is related to the Default value you set in the DateValue5, HourValue1 and MinuteValue1control.

     

    The Now() function would be calculated immediately when type the Now() function in above these controls, and this function could only be executed once time, it would not be updated automatically.

     

    When you add a new entry (the Edit form is in New Mode), the Now() function would be executed once time. And when you submit your form data, the Now() function would not be executed once again.

     

    As an fixed solution, I agree with @Mr-Dang-MSFT 's thought almost. You could consider store current date time value into a variable. And when you submit your form data, update this variable to current date time value.

     

    I have made a test on my side, please try the following workaround:

    Set the OnVisible property of the Edit form screen to following:

    Set(CurrentTime, Now())

     

    In your Edit form, Set the DefaultDate property of DataValue5 to following:

    CurrentTime

    set the Default property of the HourValue1 to following:

    Text(Hour(CurrentTime),"[$-en-US]00")

    set the Default property of the MinuteValue1 to following:

    Text(Minute(CurrentTime),"[$-en-US]00")

     

    Set the OnSelect property of the "Submit" button to following:

    Set(CurrentTime, Now()); // Add this formula to update the CurrentTime variable
    SubmitForm(EditForm_InvestmentChecklist)

     

    Please try above solution, hope it could solve your problem.

     

    Regards,

  • lesotho_kid Profile Picture
    106 on at

    Thank you @Mr-Dang-MSFT  that worked!
    Also, than you to @v-xida-msft 

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard