JavaScript method: SCFile.doUpdate()

This method updates a Service Manager record with any new field values defined in a Service Manager file object. It requires defining a Service Manager file object and defining new values for fields.

Syntax

SCFile_object.doUpdate();

Arguments

There are no arguments for this method.

Return values

RC_SUCCESS or one of the other global return code values.

The method returns RC_SUCCESS if the method successfully updates a record or returns one of the error global return code values if the method cannot update the record.

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 valid field value update (for example, set the "user.type" field to "site")
var contactName;

function updateContact( name )
{
 print( "Searching for contact: " + name + "..." );
 var contactList = new SCFile( "contacts" );
 var isContact = contactList.doSelect( "contact.name=\""+ name + "\"" );
 if ( isContact == RC_SUCCESS )
 {
  print( "Success. found " + name + " in contact record:\n" + contactList.getText() );
  print( "The current contents of the user.type field are " + contactList.user_type );
  print( "Updating the user.type field..." );
  contactList.user_type = "site";
  contactList.doUpdate();
  print( "The contents of the user.type field are now " + contactList.user_type );
  return contactList
 }
 else
 {
  print( "Could not find contact. " + RCtoString( isContact ) );
  return null
 }
}

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