locked
CRM - Set the Time portion of a Date ONLY Field RRS feed

  • Question


  • I have a date field in CRM (Agreement Date) if some users in East Coast enter a date to this field and I opened it in Pacific Time Zone (Seattle) there is one day difference. They entered agreement data as 1/1/1014 EST but I am seeing it at 12/31/2013 PST. Is there a java script to make this time difference to look same for all user when they open this account record? 

    FYI: new_agreementdate is Data and Time type with Date only Format on account record

    I use the following code but it doesn’t work….. Any idea?

    function Form_Create()

    {

    var oDate; 

                       oDate =  Xrm.Page.getAttribute("new_agreementdate").getValue() ;

                       if (oDate != null) {     

                                oDate = new Date(oDate);                   

                               oDate = oDate.setHours(12,0,0);

                              }}

    Thanks,


    • Edited by CRM Addis Tuesday, February 18, 2014 7:29 PM update
    Tuesday, February 18, 2014 7:29 PM

All replies

  • Are you then using Xrm.Page.getAttribute("new_agreementdate").setValue(oDate); to set the form field value somewhere?  I didn't see that here.
    Tuesday, February 18, 2014 7:51 PM
  • The full code is like this ........

    function Form_Create()

    {

    var oDate; 

                       oDate =  Xrm.Page.getAttribute("new_agreementdate").getValue() ;

                       if (oDate != null) {     

                                oDate = new Date(oDate);                   

                               oDate = oDate.setHours(12,0,0);

                              }

              Xrm.Page.getAttribute("new_agreementdate").setValue(oDate);

    }

    doesn't work I have no idea why?

    Thanks,

    Tuesday, February 18, 2014 8:49 PM