Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

JS Script for an Alert if Date Field does not equal Today

(0) ShareShare
ReportReport
Posted on by 10

I have a Date field in our system, and Users just cannot get the date right... which 90% of the time should be Todays' date. But the other 10%... could be any date.

I would love to create a pop-up alert to warn Users that their date may be incorrect on change of this field.

Basically, if "Date_of_Service" <> Today(), create an Alert "The Date you entered is not Today's Date. Please confirm." 

But I don't want to do this On Save, because they still need the option to change or keep that value prior to saving. 

My other question is if I need to take into consideration the UTC time of "Today" in Dynamics. So if my User is in the East Coast or Hawaii, how do I determine "Today" as local?

Thanks in advance!

  • Suggested answer
    RE: JS Script for an Alert if Date Field does not equal Today

    Hi gsfortis,

    there are different approaches for this requirement.

    If you want to implement client side logic you can work with an "OnChange" handler, as your custom validation will kick in when the date value is changed and will run prior to any save action:

    docs.microsoft.com/.../configure-event-handlers-legacy

    OnChange Occurs when data in the column changes and the control loses focus.

    You can also consider having your validation done on Server side, where you can explore creating a plugin running on Pre-Validation stage. You can review below documentation to get familiar with the different events existing in the execution pipeline.

    https://docs.microsoft.com/en-us/powerapps/developer/data-platform/register-plug-in#event-pipeline-stage-of-execution

    Finally, for a low code approach you can also consider implementing business rules:

    https://docs.microsoft.com/en-us/powerapps/maker/data-platform/data-platform-create-business-rule

    Regarding your ask about the date and UTC, it really depends on your requirements.

    Depending on how the datetime behavior is configured for your respective date fields/columns, you may or may not need to do additional UTC calculation. Please review below documentation to understand more about the date time behaviors:

    https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/behavior-format-date-time-field

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans