JavaScript method: SCFile.doSelect()

This method queries for records in an Service Manager object. The SCFile object has the following format: table={["field value",{"array value","array value"},...]}

For performance improvement, you can use SCFile.setFields method to limit the fields that doSelect returns from the database.

Note This method is used for retrieving normal data, not for retrieving attachments. If you use this method to retrieve attachments, you could corrupt the SYSATTACHMENTS table. If you need to retrieve attachments, use one of the following functions to get the attachments associated with the current file record: SCFile.getAttachment(attachID) or SCFile.getAtttachments().

Syntax

SCFile_object.doSelect( query );

Arguments

The following arguments are valid for this method:

Argument Data type Description
query String This argument specifies the query you want to use to search for Service Manager records. You must use the slash character to escape out quotation marks and any special characters restricted from JavaScript.

Return values

An SCFile object containing records and RC_SUCCESS or one of the other global return code values.

The method returns an SCFile object containing the records matching the query and a global return code value of RC_SUCCESS or returns one of the error global return code values if the method cannot return any records.

Example

This example does the following:

  • Searches the contacts table for any contact name you define in the search variable
  • Displays the contact record as a text string

This example requires the following sample data:

  • A valid contact name (for example, "ADMINISTRATOR, SYSTEM")
  • A invalid contact name (for example, "NOT A, CONTACT")
var contactName;

function findContactName( name )
{
 print( "Searching for contact: " + name + "..." );
 var contactList = new SCFile( "contacts" );
 var findContact = contactList.doSelect( "contact.name=\""+ name + "\"" )
 if ( findContact == RC_SUCCESS )
 {
  print( "Success. found " + name + " in contact record:\n" + contactList.getText() );
  return contactList
 }
 else
 {
  print( "Could not find contact. " + RCtoString( findContact ) );
  return null
 }
}

contactName = "ADMINISTRATOR, SYSTEM";
findContactName( contactName );

contactName = "NOT A, CONTACT";
findContactName( contactName );

JavaScript object: SCFile
JavaScript method: SCFile.setFields()