Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Script Check if a date & time field is empty

(0) ShareShare
ReportReport
Posted on by

Hello,

I need to check whether a date & time field in the form I use is empty, and I need to do it with Java Script (it's necessary for a function I'm using, so business rules aren't an option).

I came up with this, but it isn't working (apparently, a date & time field isn't equaling null even though it appears to be empty):

if(Xrm.Page.getAttribute('new_dateandtime') == null) {...}

Does anyone know what an empty date & time field contains or could anyone help me in some other way? Thanks a lot!

*This post is locked for comments

  • Verified answer
    tpeschat Profile Picture
    tpeschat 4,926 on at
    RE: Script Check if a date & time field is empty

    Hi.

    Try this code instead:

    var vDate = Xrm.Page.getAttribute('new_dateandtime').getValue();

    if (vDate == null) {

    }

    BR Thomas

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,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans