cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RobynPr
Advocate I
Advocate I

SubmitForm is not updating DateTime fields with Now()

Hi

I have just noticed that a datetime column that is being submitted with the current time - Now() was not being updated with the timestamp.  The Updated attribute of the column is set to Now(). Subsequent submits use the time from the first submit.

This seems to have started after UTC 2020-06-01 06:00:00 after examining my data.


I believe this to be a bug and should only take 5 minutes to reproduce.


To reproduce the problem:-

1. create a sharepoint list and add one column that is a date with time column. 
2. create the default app over the sharepoint list. 
3. change the Update attribute of the datetime datacard in the default app's EditForm1 to Now()

Run the app and add a record - the first one works. Submitting more new records leaves the datetime as the first submitted.

I'm using SQL Server, and the same thing is happening there.

I hope you can help.

Robyn

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi

 

instead of using a timer, another simpler workaround to the bug is:-

 

On the Submit button of your form screen, capture the timestamp:-

 

UpdateContext({timestamp: Text(Now(),"yyyy-mm-dd hh:mm:ss.sss")});
SubmitForm(EditForm1)

 

On the Update attribute of your datetime datacard include:-

 

DateTimeValue(timestamp)

 

 Adjust accordingly if saving as UTC, or if you don't want to update if doing an EditForm and not a NewForm.

Cheers

View solution in original post

9 REPLIES 9
iamvivran
Advocate II
Advocate II

I had faced this issue once for SQL server, then I believe I captured the datetime stamp at the SQL level, instead of capturing at Power Apps.

 

Cheers!

Vivek

v-bofeng-msft
Community Support
Community Support

Hi @RobynPr :

Firstly,let me explain why you encount this problem.

The point is Now and Today are volatile functions. Each time one of these functions is evaluated it returns a different value.

When used in a data flow formula, a volatile function will only return a different value if the formula in which it appears is reevaluated. If nothing else changes in the formula then it will have the same value throughout the execution of your app.

For example, a label control with Label1.Text = Now() will not change while your app is active. Only closing and reopening the app will result in a new value.

Secondly,Instead of using Now() in the Default property set the Default to use the value of a variable.  Then in the timerEnd property of the timer set the value of  Now().  

For example:

1\Set the OnStart property to:

 

Set(Var,Now()) /*Var is my custom variable*/

 

2\Add a timer:

Duration:

 

5000 /*loop in 5 s*/

 

AutoStart:

 

true

 

Repeat:

 

true

 

OnTimerEnd:

 

Set(Var,Now()) /*Var is my custom variable*/

 

Visible:

 

false

 

Best Regards,

Bof

Hi @v-bofeng-msft 

Thanks for your reply.

 

So shouldn't a reevaluation be done on SubmitForm or ResetForm?

 

If PowerApps is meant to be low/no code and you have to include timers and the like to simply put a timestamp on a submitted record, this is contrary to the principles of the product. 

 

Also, it seems that this behaviour has changed from June 1, 2020 as my App has been around for some time without this problem.

 

I hope the two points I make are considered.

 

Thanks

Hi @RobynPr :

I think your opinion makes sense.

If you want PowerApp to make improvements in this regard,I suggest you post your ideas to the following forum:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

At present, in order to make your app work properly, I suggest you to modify it according to the scheme I provided.

Best Regards,

Bof

Hi

 

And to the point about the behaviour changing on 1 June 2020?

 

Thanks

Hi

 

instead of using a timer, another simpler workaround to the bug is:-

 

On the Submit button of your form screen, capture the timestamp:-

 

UpdateContext({timestamp: Text(Now(),"yyyy-mm-dd hh:mm:ss.sss")});
SubmitForm(EditForm1)

 

On the Update attribute of your datetime datacard include:-

 

DateTimeValue(timestamp)

 

 Adjust accordingly if saving as UTC, or if you don't want to update if doing an EditForm and not a NewForm.

Cheers

View solution in original post

Hi @RobynPr :

Wonderful idea!

I suggest you mark this idea as a solution so that more people can see it.

Best Regards,

Bof

I have the timer implemented on the main screen of my app, and I want to use that updated time variable on other screens.  I see the timer variable doesn't update when i'm on another screen.  Is there a way for the timer to keep running while on another screen?

peronis
Frequent Visitor

I put a hidden timer on each screen. And it is working.  Consider this closed.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (18,960)