JavaScript method: SCFile.setRecord()

Sets the SCFile field values from a given XML string.

Syntax

SCFile_object.setRecord();

Argument

setRecord("xmlstring");

Example

function updateContactPhoneFromXML( name, xmlstr )
{
    print("Searching for contact: "+ name + "...");
    var contactRecord = new SCFile("contacts");
    var rc = contactRecord.doSelect( "contact.name=\""+ name + "\"" );
    if ( rc == RC_SUCCESS)
    {
        print("found contact " + name + ", phone number:\n" + contactRecord.contact_phone.toString() );
        contactRecord.setRecord(xmlstr);
        contactRecord.doUpdate();
        print("updated phone number in contact record:\n" + contactRecord.contact_phone.toString());
    }
    else
    {
        print("Could not find contact. " + RCtoString( rc ) );
    }
}

var contactName = "ADMINISTRATOR, SYSTEM";
var xmlString = "<model name=\"contacts\" query=\"contact.name="ADMINISTRATOR, SYSTEM"\"><keys><contact.name sctype=\"string\">ADMINISTRATOR, SYSTEM</contact.name></keys><instance recordid=\"ADMINISTRATOR, SYSTEM\" uniquequery=\"contact.name="ADMINISTRATOR, SYSTEM"\"><contact.name mandatory=\"true\" type=\"string\">ADMINISTRATOR, SYSTEM</contact.name><contact.phone type=\"string\">(335) 123-4567</contact.phone></instance></model>";

updateContactPhoneFromXML(contactName, xmlString);

Note

  • The input XML string should follow the Service Manager File schema.
  • You cannot use setRecord() to set values for files that contain binary data. For example,you cannot use setRecord() for displaycache, code, SYSATTACHMENTS files.
  • You cannot use setRecord() to set dbdict records.