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 / Form default date does...
Power Apps
Unanswered

Form default date doesn't change when app is left open into the next day

(0) ShareShare
ReportReport
Posted on by 25

I recently built an app that is basically a kiosk and is always open. We operate 24/7, so my users submit data throughout the day. My issue is when the date rolls over, the default for a date picker field does not change.

 

Some details on the app:

I have two instance of the app running at once. One is always set to the entry screen to enter data, and the other monitor displays a gallery with all the items. This is to say that the entry screen is almost always open and isn't generally used to navigate/view items.

 

The entry screen uses a form control to collect data, including a date. The default for the date is set with the following code:

 

If(FormNewCallEntry.Mode = FormMode.New,
 If(Hour(Now()) >= 6,
 Today(),
 Today() - 1),
 Parent.Default
)

 

The time offset is to account for shift change which happens at 6 AM.

When a user hits a save button, it calls SubmitForm and the form OnSuccess calls the ResetFrom action.

 

The Problem:

If you open the app fresh, this all works great and the defaults fill in properly. However, if you have the app open before 6 AM and create a new form after 6 AM, the date default doesn't change and still shows the previous day. You can navigate between screens and call NewForm all you want, but the previous day still populates. This ends up causing problems for my users when they don't notice and enter data with the wrong date.

 

The only way I found to fix this (without completely reloading the app) is to open a different record with the form in edit mode. Once you do this, calling a new form now loads the correct defaults. I could try to do some sort of refresh that does this set of actions via code triggered by a timer, but it seems like a kluge.

 

Does anyone have a better way, or even better, a fix to the underlying problem?

Categories:
I have the same question (0)
  • SebS Profile Picture
    4,582 Moderator on at

    Hi @entonticuptusbo 

     

    Did you try to add to Screen property called OnVisible a Reset(DatePicker). Each time someone change screen to that screen with form when you add this function the Date Picker will reset and should refresh default value have a look if this works.

     

     

    Regards 

  • entonticuptusbo Profile Picture
    25 on at

    Hi @SebS,

     

    So I tried resetting the individual control, and that didn't help.

     

    On the date picker, I set the Reset value to a global variable named varResetDate.

    To just give it a try first to see if it works first, I assigned the following code to a button. (Note, FormNewCallEntry is the form the date picker control is in.)

    ResetForm(FormNewCallEntry);
    Set(varResetDate,true);Set(varResetDate,false);
    Set(varResetShift,true);Set(varResetShift,false)

    I let the app run overnight and this morning gave it a try. The date in the date picker did not update to today's date when I pressed the button. Even if I picked another date, when I pressed the reset button, it reverted to yesterday's date.

  • Verified answer
    AaronKnox Profile Picture
    514 Super User 2024 Season 1 on at

    This is an interesting problem and I'm curious how we can fix this.  If resetting the controls doesn't trigger the Now() to 'refresh/update' you may want to try using a variable that has the 'Now() formula' and then set this variable instead of resetting the control:

    Set(gbllToday, 
     If(Hour(Now()) >= 6,
     Today(),
     Today() - 1
     )
    )

     

    For instance, you could have a button that says 'Start a new entry' that users have to click on to begin.  That OnSelect could include the above code.  Then the default would be something like this:

    If(FormNewCallEntry.Mode = FormMode.New,
     gblToday,
     Parent.Default
    )

     

     

  • Verified answer
    cmitchener Profile Picture
    on at

    Another thing you could do is use a timer. It is a bit clunky, but it does work. You would set the date picker default date to a variable (varTodaysDate, for example), then put this in the OnTimerEnd:

     

    Set(

       varTodaysDate,

       If(FormNewCallEntry.Mode = FormMode.New,

          If(Hour(Now()) >= 6,

             Today(),

             Today() - 1),

          Parent.Default

       )

    )

     

    This would update the date every time the timer ended, so you would just set the timer to automatically start, turn off autopausing, turn on repeat, and set the time to whatever you wanted it to be (keep in mind it is counted in miliseconds, so 1000 in the time is 1 second).

  • entonticuptusbo Profile Picture
    25 on at

    I'll give the variable suggestion a try. Since I'm off Fri/Sat/Sun this week, I'll report back my findings on Monday.

  • entonticuptusbo Profile Picture
    25 on at

    The variable worked. I tested it with a button, but I'll add it using a timer to refresh to for the production environment.

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard