JavaScript method: SCFile/SCDatum.getType()

This method returns the data type of HPE Service Manager datum objects, such as arrays and structured arrays. This method fails on any scalar fields within file records, such as number fields, date fields, string fields, and boolean fields. To determine the type of scalar fields you can use, see the core JavaScript .type property in the JavaScript Guide at http://developer.mozilla.org/.

Syntax

SCFile_object.getType();
SCDatum_object.getType();

Arguments

There are no arguments for this method.

Return values

A data type and RC_SUCCESS or one of the other global return code values.

The method returns a data type and a global return code value of RC_SUCCESS or returns one of the error global return code values, if the method cannot determine the data type.

Example

This example does the following:

  • Searches the probsummary table for any incident record you define in the search variable
  • Displays the contents of the incident record object
  • Returns the data type of the incident record object using the getType() method
  • Displays the contents of the action field object
  • Returns the data type of the action field object using the getType() method
  • Displays the contents of the category field
  • Returns the data type of the category field object using the core JavaScript type property

This example requires the following sample data:

  • A valid incident record (for example, "IM1001")
var incidentQuery;

function findTypes( query )
{
 print( "Searching for incident records starting with " + query + "..." );
 var incidentFile = new SCFile( "probsummary" );
 var findIncident = incidentFile.doSelect( "number#\""+ query + "\"" );
 if ( findIncident == RC_SUCCESS )
 {
  print( "Success. Found incident records starting with " + query + ". The first record is:\n" + incidentFile );
  var objectType = incidentFile.getType();
  print( "The object incidentFile is of type: " + objectType );
  var arrayField = incidentFile.action;
  print( "The contents of the action field are:\n" + arrayField );
  fieldType = arrayField.getType();
  print( "The type of the action field is: " + fieldType );
  var textField = incidentFile.category;
  print( "The contents of the category field are:\n" + textField );
  fieldType = textField.getType;
  print( "The type of the category field is: " + fieldType );
 }
 else
 {
  print( "Could not find incident records starting with " + query + ". " + RCtoString( findIncident ) );
  return null
 }
}

incidentQuery = "IM1001";
findTypes( incidentQuery );