Add

Adds a new object or updates an existing object.

Syntax

            <Add type="ObjectType" attr_name1="attr_value1" attr_name2="attr_value2">
   <ObjectType>
      <property1>value1</property1>
      <property2>value2</property2>
        ... 
   </ObjectType>
</Add> 

          

Usage

Use the Add command to add or update an object. The maximum number of objects you can add or update with one XML API call is 1,000.

The Add command cannot be used to add User objects. Use CreateUser instead.

You can set custom field values as well as standard field values when adding objects. See Reading or Setting Custom Field Values Inline.

Attributes

Attribute

Usage

enable_custom

XML API Only — Set the enable_custom attribute to 1 to include custom field values in the argument object properties along with standard object properties.

lookup

Use the lookup to upsert an object and designate the lookup field. The lookup field determines whether it adds or updates an object:

  • If the lookup field is not matched in any existing objects, a new object is added.

  • If the lookup field is matched one time, the existing object is updated.

Arguments

Name

Type

Description

ObjectType

Object

The object to add or update.

Response

ObjectType — The added or updated object with all properties including the object internal ID [id], date created timestamp [created], and date updated timestamp [updated].

Sample Code — Upsert

The following example looks up a Category object with name="XML-created category 1", updates the external ID of the matching Category object, if it exists, or adds the object otherwise.

            <Add type="Category" lookup="name">
   <Category>
      <name>XML-created category 1</name>
      <externalid>111-2222</externalid>
   </Category>
</Add> 

          

Sample Code — Adding CV as Attachment to a Resource Profile

The following example adds a CV as attachment to an employee's resource profile. This is a two step process:

  1. Add a ResourceAttachment object.

  2. Add the attachment file as base64 encoded data. Set the ownerid property of the Attachment object to the internal ID of the ResourceAttachment object added in the previous step.

            // Step 1 - Add a ResourceAttachment object
<Add type="ResourceAttachment">
   <ResourceAttachment>
      <type>CV</type>
      <userid>123</userid>
   </ResourceAttachment>
</Add>

// Step 2 - Upload the CV as Attachment with ownerid set to the
// internal ID of the ResourceAttachment object added in Step 1 
<Add type="Attachment">
   <Attachment>
      <base64_data>U25lemth</base64_data>
      <file_name>Collins_Marc_CV.txt</file_name>
      <owner_type>ResourceAttachment</owner_type>
      <ownerid>98765</ownerid>
   </Attachment>
</Add>