JavaScript method: SCDatum.JSDate()

This method is deprecated as of version 6.1 with the introduction of the SCFile object. This method converted ITSMA Service Management date/time data into JavaScript date/time objects. The SCFile object now automatically converts Service Management date/time data into JavaScript date/time objects. Alternatively, you can now use the XMLDate object and its methods to convert between date/time formats.

Syntax

SCDatum_object.JSDate( dataType );

Arguments

The following arguments are valid for this method:

Argument Data type Description
dataType String This argument specifies the data type of a field in an SCDatum object.

Return values

None

Example

This example does the following:

  • Searches the probsummary table for any incident record you define in the search variable
  • Displays the incident record and the value of the open.time field
  • Creates an SCDatum object containing the number of milliseconds you want to convert
  • Converts the open.time field into an SCDatum object (by default the open.time field data is in Service Management's date/time data type)
  • Converts the SCDatum object into a JavaScript date/time

This example requires the following sample data:

  • A valid incident record with a value in the open.time field (for example, "IM1010")
var incidentID;

function findIncident( id )
{
 print( "Searching for incident: " + id + "..." );
 var incidentFile = new SCFile( "probsummary" );
 var f = incidentFile.doSelect( "number=\""+ id + "\"" );
 if ( f == RC_SUCCESS )
 {
  print( "Success. found " + id + " in incident record:\n" + incidentFile.getText() );
  print( "The value of the open.time field is: " + incidentFile.open_time );
  print( "Converting open.time to an SCDatum object..." );
  var dat = new SCDatum( incidentFile.open_time );
  print( "The new SCDatum object is: " + dat );
  print( "Converting the SCDatum object to a JSDate..." );
  var j = dat.JSDate();
  print( "The converted SCDatum object is: " + j );
  return incidentFile
 }
 else
 {
  print( "Could not find incident record. " + RCtoString( f ) );
  return null
 }
}

incidentID = "IM1010";
findIncident( incidentID );