Salesforce APIs used for Writing

Background

One Record At a Time

Salesforce supplies several API’s for writing data. The standard REST API creates/updates an individual object (or record) with a single API call.

This suffers from several issues:

  • Slow - each create/update operation must be made individually.
  • High API Usage - Each operation consumes a single API call.
  • Parent - Child Relationships - If parent-child type data required updating not only would the parent require a call but also each object child object; there and sometimes also another API call for some objects to link a child to it's parent. For example linking PriceBookEntries to Products.

IMan's Handling

To counter this simplistic approach the connector uses a combination of the Salesforce tree and composite APIs which allow us to batch multiple insert/update operations. These two APIs have been to used to match most closely the IMan's model for ensuring data integrity and transactional handling of data and provide the necessary performance to update 10k's records.

Salesforce TREE API Usage

The Tree API will be used in the following circumstances:

  • The Update Operation is Insert only, the Salesforce Id is mapped and the Action on Transform Error is set to Abort.
  • The Update Operation is Insert/Update and the Salesforce Id is not mapped.

The Tree API is used by the connector to insert new objects in bulk. When inserting records IMan issues batches of 200 records.

Each batch is executed concurrently, where the maximum

Error Handling

If any object within a batch of data has an invalid value, or a required field is empty or missing, the entire batch will be rejected by Salesforce.

Due to the concurrent nature of processing, a scenario may occur where several batches will succeed, but an error in one batch will cause it to fail.

Salesforce COMPOSITE API Usage

The composite API is used in the following scenarios:

  • The Update Operation is set to Update or Insert/Update
  • The data contains a Salesforce Id which is mapped to the Id field on the object.
  • The Action on Transform Error is set to Reject Record.

The composite call can insert or update up to 25 objects at a time, it can optionally treat those objects as a single transaction.

The composite API is used by Salesforce to chain requests together, it can be used to batch inserts and updates as well as link certain objects together all in a single API call.

Error Handling

The Composite API's transactional ability to group objects closely aligns to Reject Record.

If an error occurs.....