JavaScript object: Datum

The Datum JavaScript object is unique to Service Manager. This JavaScript object was deprecated as of ServiceCenter 6.1 because this object's methods can only return true or false boolean values. You can use the SCFile or SCDatum objects in place of this object to take advantage of the improved return code values.

With no parameters, the Datum() constructor creates an empty Datum object.

With an Object parameter, the Datum() constructor creates a Service Manager-formatted Datum object containing the provided record, structure, or array. You must enclose table names and arrays in quotation marks. You can use the Datum object as a parameter for RTECall routines that expect Service Manager-formatted parameters.

Constructor

new Datum();
new Datum(Object);

Arguments

The following arguments are valid for this object:

Argument Data type Description
Object String The Service Manager table name, record, structure, or array you want to query or update.

Properties

None

Methods

The following methods are valid for this object:

Defined method Description
getText() This method returns a text representation of the object.
getXML() This method returns an XML representation of the object.
getSize() This method returns the size of the object.
getMessages() This method returns an array of messages generated by the Document Engine from a previous SCFile.doAction().
length() This method returns the length of the object.
getNext() This method moves to the next record if the object represents a result set.
getPrev() This method moves to the previous record if the object represents a result set.
getFirst() This method moves to the first record if the object represents a result set.
getLast() This method moves to the last record if the object represents a result set.
doSelect() This method makes a query. It no longer requires that the first argument be the name of the table if the object is constructed with the name of the table.
isRecord() This method checks if an object represents a current table and has a record.
getType() This method returns the object type.
doUpdate() This method updates the database.
doInsert() This method inserts an object into the database.
doRemove() This method removes an object from the database.
doDelete() This method is synonymous with the doRemove method. This method simply has a more intuitive name.
doAction() This method executes a method defined on the object.
toArray() This method converts an object to a JavaScript array.
push() This method adds an item to an array.
pop() This method removes an item from an array.
join() This method returns a string of all the entries in the array.
shift() This method returns a string of all the entries in the array.
unshift() This method returns a string of all the entries in the array.
setType() This method sets the object type.
setValue() This method sets the object to a given value.
doSave() This method inserts a record if it is new and updates the record if it already exists.
JSDate() This method returns a JavaScript Date object.

Example

This example does the following:

  • Creates a Datum object from the contacts table
  • Selects records from this contacts table starting with the letter B
  • Displays the contacts matching the select query

This example requires the following sample data:

  • A valid query against the contacts table (for example, contact.name # "B")
var q = new Datum( "contacts" );
if ( ( q.soSelect( "contact.name # \"B\"" ) ) == true )
{
  print( q.getText() );
}
else
  print( "No contacts start with B" );