JavaScript method: SCFile.doCount()

This method returns the number of records specified by the query.

Note You should not use this method on an SCFile object for which you have performed a previous doSelect() if you intend to iterate over the results of the doSelect().

Syntax

SCFile_object.doCount( "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 Management records. You must use the slash character to escape out quotation marks and any special characters restricted from JavaScript.

Return values

A number representing the count of records.

Example

This example does the following:

  • Determines the number of contact records.
  • Displays the contact record as a text string.

This example requires the following sample data:

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

function countContacts( location )
{
    print( "Counting contacts at location: " + location + "..." );
    var contactList = new SCFile( "contacts" );
    var nCount = contactList.doCount( "location=\""+ location + 
		  "\"" );
    var rc = getLastRC();
    if ( rc == RC_SUCCESS )
    {
      return nCount;  
    }
    else
    {
      print( "Could not count records. " + RCtoString( rc ) );
      return -1;
    }
}