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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Unable to get OnChange Event For DateTime Picker

(0) ShareShare
ReportReport
Posted on by 158

I need to get the onChange event for a date time picker in CRM Portals.  I have been working on this all morning and trying everything Google kicks back at me.  Here are the links I have tried that did not work:

https://community.dynamics.com/crm/f/117/t/229657

http://mscrm365.blogspot.sg/2017/08/trigger-datepicker-onchange-event-in.html

http://arpitmscrmhunt.blogspot.in/2017/05/set-or-auto-populate-value-in-date.html

https://community.adxstudio.com/forums/adxstudio-portals/80b560ef-45dc-e311-80c6-00155dc0a3d4

Here is the html from debugger:

7563.Capture.PNG

All other change events are working just fine with my custom JQuery, but when dealing with a date time picker I can't get it.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    jestuder Profile Picture
    158 on at

    I reached out to Microsoft on this one and took what they gave me and had to update it since I am using session memory.  Here is how to get this to work:

    Step 1 :- Click on the datetime control. Then press F12 à Go to console and write $('div.control') and hit enter. From the list of div.controls find out the div.control which contains your datetime field. In my case it is 2.

    sa2.png

    Step 2 : Got to the entityform or if it is not an entityform then use inline editing and add this custom js.

    $(document).ready(function () {

        var dpcontrol = $('div.control')[2];

        $(dpcontrol).on("dp.change", function (e) {

            alert("On change Event Triggered");

            alert(e.date);

        });

    });

    sa2.png

    <<<< If you need to read and write this value to session memory here is a code snippet to do that: >>>>

    $(document).ready(function () {
        var dpcontrol = $('div.control')[0];
        $(dpcontrol).on("dp.change", function (e) { sessionStorage.setItem('#IDOFDATETIME', e.date); });
    
        var memoryDate = new Date(GetSessionValue('#IDOFDATETIME'));
        var shortDate = (memoryDate.getMonth() + 1 + '/' + memoryDate.getDate() + '/' + memoryDate.getFullYear());
        $('input[aria-describedby="IDOFDATETIME_description"]').val(shortDate);
    });
    
    function GetSessionValue(fieldname) {
        var sessionValue = sessionStorage.getItem(fieldname);
        return sessionValue;
    }


  • Hemant Kumar Sahu Profile Picture
    1,829 on at

    Thanks James Studer.

    Event I wasted my half day on this.

  • Guillermo Zopedro Profile Picture
    40 on at

    Hi James! Thanks man! This helped me a lot. I was going through this around a couple of weeks.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans