locked
CRM 4: Date & Time Field to null after the user selects a Date RRS feed

  • Question

  • Hey Guys,

     

    I have some code that I am using to change the option picklist in a date & time field to only show working hours. However, after the Date is selected on the field the time shows 12:00AM how can I change that to be null or show blank? or show a specific value?

    Thanks

    Dylan

    Thursday, July 14, 2011 6:47 PM

All replies

  • Hi,

    I am not sure that it can be done. If so using a javascript. The problem is that the date and time fields are connected to the same data and there cannot be data in one without there being data in the other. Defaulting it is probably the best way to handle it. Another way might be to have a separate drop-down attribute for the time and then setting the time on the date-time using javascript or plugins when it is saved.

     


    Gustaf Westerlund, CEO and Chief Architect at CRM-Konsulterna in Sweden
    Blog: http://gustafwesterlund.blogspot.com
    Swedish Dyn CRM Forum: http://www.crmforum.se
    Friday, August 5, 2011 12:41 PM
  • Your best bet is to get it to show a different value e.g. set it to 09:00AM instead of 12:00AM. I haven't tested this in CRM but something like the following in the onChange event of the date field should do the trick:

    var myDate = crmForm.all.new_date.DataValue;
    
    if(myDate.getHours() == 0)
    
    {
    
     myDate.setHours(9);
    
     crmForm.all.new_date.DataValue = myDate;
    
    }
    
    Friday, August 5, 2011 1:45 PM
  • Hi,

    If CRM finds a null value in the date and time field then it automatically populates the time value to 12:00AM either you can set any other value or can hide the time field and will show once date value will be selected.

    Hide Time Field (Its works altough unsupported Customization)

     

    document.getElementById("new_fieldname").childNodes[1].childNodes[0].childNodes[0].style.display = "none";
    
    document.getElementById("new_fieldname").childNodes[1].childNodes[0].childNodes[1].style.display = "none";
    

     


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, August 5, 2011 2:02 PM