Date/Time fields will not display

nicolemccray
Tera Expert

I've written some script to get my form values to
display in a Case/Task.   All are displaying correctly, except for the
Date/Time values (start date and end date).   They show in the task and email notification as blank.   Here is a snippet
of the code:

notes += '\nTraining Start Date/Time: ' +
current.variables.start_date.getDisplayValue();

notes += '\nTraining End Date/Time: ' +
current.variables.end_date.getDisplayValue();

notes += '\nTotal Number of Training Days: ' +
current.variables.total_days;

notes += '\nLocation of Training: ' +
current.variables.location_training;

notes += '\nNumber of Attendees: ' +
current.variables.number_attendees;

Could this be a result of the client script I have to make
the field read only so the requestor has to use the calendar picker?

function onLoad() {

  // Sets the field's background to a gray, making
is appear read-only.  

  g_form.getControl('start_date').className='disabled';

  // Sets the field read-only  

  g_form.getControl('start_date').readOnly=true;

1 ACCEPTED SOLUTION

I've verified that the issue was due to placing the disabled class on my fields:


"g_form.getControl('end_date').className='disabled';"



Changing the client script to the following resolved the issue:



function onLoad() {


       
// Sets the field's background to a gray, making is appear read-only.  


  g_form.getControl('end_date').disabled
= 'true';  


  // Sets the field
read-only  


  g_form.getControl('end_date').readOnly=true;



}


View solution in original post

2 REPLIES 2

davidpanson
Mega Expert

I've had similar problems working with Date/Time fields and them not displaying. In my case it is almost always due to variable type confusion. It can be tricky to know if your information is actually being returned as a Date/Time Value or just a string formatted that looks identical to a Date/Time value. And of course both have different display methods. I would generally recommend making absolutely sure you know if it's a string or Date/Time and making sure you're trying to display it as such.



Also double check your dictionary entries to make sure that end_date and start_date are the correct column names.



But considering it's only Date/Time fields you're having trouble with my first instinct is check variable formatting.


I've verified that the issue was due to placing the disabled class on my fields:


"g_form.getControl('end_date').className='disabled';"



Changing the client script to the following resolved the issue:



function onLoad() {


       
// Sets the field's background to a gray, making is appear read-only.  


  g_form.getControl('end_date').disabled
= 'true';  


  // Sets the field
read-only  


  g_form.getControl('end_date').readOnly=true;



}