JavaScript global properties

Global properties are predefined properties that are not part of any object. They are names representing values that are globally defined. The core JavaScript language has several global properties, such as NaN (Not a Number), and Service Manager has a number of additional global properties.

There are two categories of Service Manager-defined global properties:

  • Query operators
  • JavaScript return code properties

Query operators

These operators are used solely for constructing query expressions using the Query object.

Note The Query object has been deprecated, but older JavaScript code within the ScriptLibrary still uses the object.

Query operator Description

EQ

Equals to

LIKE

Starts with

NEQ

Not equal to

GT

Greater than

GE

Greater or equal to

LT

Lower than

LE

Lower or equal to

ISIN

Is an element in the array

Example:

var q=new SCFile("probsummary")
q.doSelect(new QueryCond("number", EQ, "IM10002"));

JavaScript return code properties

Use these properties (which are represented internally as integer values) to test the values returned by object methods such as SCFile. To print the error message rather than the return code, use the RCtoString function.

Return code Description

RC_ERROR

Some other error occurred. Examine the contents of the Messages view or the sm.log file for more information.

RC_SUCCESS

The operation succeeded.

RC_CANT_HAVE

The operation failed because the resource is unavailable because some other user or process has the resource locked.

RC_NO_MORE

No more records are available in the result set.

RC_DUPLICATE_KEY

The insert operation failed because the file already contains a record with this unique key value.

RC_MODIFIED

The update operation failed because the record was modified by another user or process since you read it.

RC_DELETED

The operation failed because the record was deleted by another user or process.

RC_BAD_QUERY

The query failed due to incorrect query syntax.

RC_NOT_AUTHORIZED

The request operation was not performed due to an authorization failure. Check the permissions associated with the user who submitted the request.

RC_VALIDATION_FAILED

The operation failed because the data supplied in a field or the record did not pass validity checks performed by the application.

RC_UNABLE_TO_WRITE_TO_FILE

The operation failed. Check to make sure the file name is correct, that the file exists, and that it is not read-only.

RC_UNABLE_TO_CLOSE_FILE

The operation failed. Check to make sure the file name is correct, that the file exists, and that it is not read-only.

RC_UNABLE_TO_DELETE_FILE

The operation failed. Check to make sure the file name is correct, that the file exists, and that it is not read-only.

RC_INVALID_FILENAME

The operation failed because the file name is not valid.

Example:

var rc = mySCFile.doInsert();
if ( rc == RC_SUCCESS )
{
	print( "Insert succeeded" );
}
else
	throw( "Error " + RCtoString(rc) + " occurred trying to insert a 
	record" );