JavaScript object: SCFile

The following JavaScript object is unique to Service Management.

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

With an object parameter, the SCFile() constructor creates an SCFile object containing the provided record, structure, or array. You must enclose table names and arrays in quotation marks.

This object's methods use the Service Management-defined global return codes.

Constructor

new SCFile()
new SCFile(object)
new SCFile( object, SCFILE_READONLY )

Arguments

The following arguments are valid for this object:

Argument Data type Description
object String The table name, record, structure, or array you want to query or update.
SCFILE_READONLY Number

Causes the file object to become read-only. This constant is only supported as a second parameter, with the file name specified as the first parameter.

Properties

None

Properties

None

Methods

The following methods are valid for this object:

Defined method Description
deleteAttachment( attachID ) This method deletes a specific attachment associated with the current file record.
deleteAttachments() This method deletes all of the attachments associated with the current file record.
doAction() This method executes a method defined on the object.
doCount() This method returns the number of records for the provided query.
doDelete() This method is synonymous with the doRemove() method. This method simply has a more intuitive name.
doInsert() This method inserts an object into the database.
doPurge() This method purges a set of records directly in the back-end RDBMS.
doRemove() This method removes an object from the database.
doSave() This method inserts a record if it is new and updates the record if it already exists.
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.
doUpdate() This method updates the database.
getAttachment( attachID ) This method gets a specific attachment associated with the current file record.
getAttachments() This method gets all of the attachments associated with the current file record.
getBinary()

This method returns the binary representation of a field in a Service Management file object.

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.
getLastRC() This method returns the last return code generated by the SCFile and SCDatum objects.
getMessages() This method returns an array of messages generated by the Document Engine from a previous doAction().
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.
getPurgedRowCount() This method retrieves the number of records deleted from a table by the doPurge().
getText() This method returns a text representation of the object.
getType() This method returns the object type.
getXML() This method returns an XML representation of the object.
insertAttachment() This method creates a new attachment associated with the current file record.
isRecord() This method checks if an object represents a current table and has a record.
setBinary() This method saves binary data to a field in a Service Management file object.
setFields() This method causes any subsequent doSelect() calls to fetch only the specified fields.
setRecord() This method sets the field values from a given XML string.
setOrderBy() This method causes any subsequent doSelect() call on a SCFile object to fetch only the specified fields by the specified sort sequences of the SCFile Object.
updateAttachment( attachObj ) This method updates a specific attachment associated with the current file record.

Example

This example does the following:

  • Creates an SCFile 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 SCFile("contacts");
if ( ( q.doSelect( "contact.name # \"B\"" ) ) == RC_SUCCESS )
{
  print(q.getText());
}
else
  print( "Return code is: " + q.RCtoString );