JavaScript method: SCFile/SCDatum.getXML()

This method returns an XML object representation of the current SCFile or SCDatum object. The XML object has the following format, which is compatible with the Service Manager Web services API:

<model name="table" query="query"><keys><fieldname>key value</fieldname>...</keys><instance><fieldname>instance value</fieldname>...</instance></model>

Syntax

SCFile_object.getXML();
SCDatum_object.getXML();

Arguments

There are no arguments for this method.

Return values

An XML object and RC_SUCCESS or one of the other global return code values.

The method returns an XML object containing the current SCFile or SCDatum object and a global return code value of RC_SUCCESS or returns one of the failure global return code values if the method cannot return an XML object.

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 an XML object

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 findContact( 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.getXML() );
  return contactList
 }
 else
 {
  print( "Could not find contact. " + RCtoString( isContact ) );
  return null
 }
}

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

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