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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Date Picker OnChange n...
Power Apps
Unanswered

Date Picker OnChange not triggering

(0) ShareShare
ReportReport
Posted on by 109

Hi,
I have a two screens "Login Screen" and "Home Screen".

When the I Log in the first time("Login Screen" navigates to "Home Screen"). the Date picker(on Home Screen) OnChange event is fired. But when I logout (navigate back to "Login Screen") and login again the Date picker OnCahnge event doesnt fire.
I need the OnChange event to fire everytime the user Logs in.

 

Thanks

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @MJK 

    What is the OnChange code? Are you setting a variable, for instance? If so, are you re-setting that variable to it's initial state when navigating back to the Login Screen?

  • MJK Profile Picture
    109 on at

    @Anonymous ,

     

    I populate a Collection in OnChange event and Clear the Collection on Logout.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @MJK 

    If you share some relevant code I'll do my best to help.

  • MJK Profile Picture
    109 on at

    @Anonymous ,

     

    OnChange code - 

     

    //Get PayrollData from database
    ClearCollect(
    PayrollData,
    'GetPayrollDataNew'.Run(
    dtpkWeekOf.SelectedDate,
    Last(LoginDetails).EmployeeId
    )
    );

     

    //Check if time entry data already exists in database
    If(
    IsEmpty(PayrollData),
    UpdateContext({record: "new"}),
    UpdateContext({record: "old"})
    );

     

    //Check if Timesheet is Approved or not
    ClearCollect(
    HoursApproved,
    Blank()
    );
    If(
    !IsEmpty(PayrollData),
    ForAll(
    PayrollDataNew,
    If(
    PayrollDataNew[@Approved] = true,
    Collect(
    HoursApproved,
    {Apprd: 1}
    )
    )
    )
    );

     

    //Check if Timesheet is Submitted or not
    ClearCollect(
    HoursSubmitted,
    Blank()
    );
    If(
    !IsEmpty(PayrollData),
    ForAll(
    PayrollDataNew,
    If(
    PayrollDataNew[@Submitted] = true,
    Collect(
    HoursSubmitted,
    {Submit: 1}
    )
    )
    )
    );

     

    //Create a new dummy record to populate the gallery if timesheet doesn't exists in the database
    If(
    IsEmpty(PayrollData),
    ClearCollect(
    PayrollData,
    {
    PayrollHoursId: 00,
    EmployeeId: Last(LoginDetails).EmployeeId,
    EmailAddress: Last(LoginDetails).EmailAddress,
    ProjectDetailId: 0,
    TaskName: "--Select--",
    WeekOf: Text(
    dtpkWeekOf.SelectedDate + Time(
    0,
    0,
    0
    )
    ),
    DayOneDate: Text(
    dtpkWeekOf.SelectedDate + Time(
    0,
    0,
    0
    )
    ),
    DayOneHours: 0,
    DayOneNote: "",
    DayTwoDate: Text(
    dtpkWeekOf.SelectedDate + 1 + Time(
    0,
    0,
    0
    )
    ),
    DayTwoHours: 0,
    DayTwoNote: "",
    DayThreeDate: Text(
    dtpkWeekOf.SelectedDate + 2 + Time(
    0,
    0,
    0
    )
    ),
    DayThreeHours: 0,
    DayThreeNote: "",
    DayFourDate: Text(
    dtpkWeekOf.SelectedDate + 3 + Time(
    0,
    0,
    0
    )
    ),
    DayFourHours: 0,
    DayFourNote: "",
    DayFiveDate: Text(
    dtpkWeekOf.SelectedDate + 4 + Time(
    0,
    0,
    0
    )
    ),
    DayFiveHours: 0,
    DayFiveNote: "",
    DaySixDate: Text(
    dtpkWeekOf.SelectedDate + 5 + Time(
    0,
    0,
    0
    )
    ),
    DaySixHours: 0,
    DaySixNote: "",
    DaySevenDate: Text(
    dtpkWeekOf.SelectedDate + 6 + Time(
    0,
    0,
    0
    )
    ),
    DaySevenHours: 0,
    DaySevenNote: "",
    Submitted: false,
    Approved: false,
    Pulled: false,
    New: true
    }
    )
    );

    Logout button OnSelect code - 

     Clear(PayrollData),
    Clear(PayrollDataNew),
    Clear(HoursApproved),
    Clear(HoursSubmitted),
    Back()

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @MJK 

    Have you done some error checking to see if you can identify where the OnChange stops? I count 6 processes and one Flow which could all fail, which one isn't working correctly? If it was me, I'd set a variable to zero then increment it by 1 between each process and check the end value using a label. If the variable reached seven then you need to check your logic.

     

    EDIT: I forgot to mention, I'm not sure if IsEmpty works as expected on collections. I think it can return true even when a collection is empty. I've always used CountRows instead, this maybe work checking as well?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @MJK 

    Did you manage to get a resolution with this issue? I'm happy to help further if needed.

  • JLincoln Profile Picture
    69 on at

    The issue is that your date control isn't changing date. I don't think the issue is, as @Anonymous suggests (not without merit), the OnChange code failing.

    I'm not sure exactly what your use case is and how you want it to work, but hopefully you can pick some useful bits out of this.

    >in the App.OnStart, Set(FirstLogIn, true);
    >On HomeScreen.OnVisible Set(FirstLogIn, false); This is the only interaction we'll have with FirstLogIn, as from the point the homescreen is navigated to onward it will be false.

    None of that changes how your app works now, which it sounds like works fine.

    In the OnSelect property of your login button on the Login screen, If( FirstLogIn = false, RUN OnChange CODE). This will do your OnChange stuff with the date that was previously selected and get a collection for your user on login.


    Not exactly the most elegant way to do this and I can think of a few cleaner ways (put the OnChange code into a button and select that button so your onChange is cleaner), but it should yield the behavior you need.

    Edit: another solution is to use the same kind of check to see if it's the first log in and set a variable to update date. Point the date picker to this variable and it should update if you set the variable to blank and then put Today() in it.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 166

#3
sannavajjala87 Profile Picture

sannavajjala87 71 Super User 2026 Season 1

Last 30 days Overall leaderboard