JavaScript method: SCFile.doSave()

This method adds to or updates the HPE Service Manager database 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.doSave();

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
  • Updates the value of the user.type field
  • Saves the Service Manager record

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";
  print( "Saving record..." );
  var rc = contactList.doSave();
  print( "The return code value for the doSave() method is: " + RCtoString( rc ) );
  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 );