Salesforce Upsert

In this article

Overview

The Salesforce Upsert Snap is a Write-type Snap that enables you to upsert (that is, a simple update or insert procedure) object records in Salesforce in Bulk API 1.0 or REST API mode. The Snap in Bulk API mode submits a batch job and writes the batch job information to the output view, which should be passed to the Salesforce Poller Snap to check the result of the batch job. More specifically, the Salesforce Upsert Snap should not be thought of as the combination of the Salesforce Update and Salesforce Create Snaps.

The Salesforce Upsert Snap operates exclusively on the External ID field, not on the Salesforce-generated record ID. If a record for a given external ID exists, the record is updated with the input record data. If no record exists for a given external ID, a new record is created with the input record data. The external ID is used as the unique record identifier from an external system and can be useful when you want to synchronize an external system to Salesforce.com

To create a new external ID field for an Account object:

  1. Log in to your Salesforce account.
  2. Go to App Setup > Customize > Account > Fields > New. 
  3. Follow the instructions and create a new custom field. 
You must select the External ID checkbox in Salesforce. The Snap in REST API mode upserts records to the Salesforce objects and returns results synchronously without the need for the Salesforce Poller Snap.


To use newer Salesforce objects, use the latest API versions where those objects are available.

Salesforce Upsert Settings

Prerequisites

None.

Limitations and Known Issues

This Snap performs batch processing, that is, a batch of input documents are processed for each HTTP request sent to Salesforce. Values of all the expression-enabled fields must remain constant during the Snap execution or validation. Hence, all expression fields can support Pipeline parameters only when they are expression-enabled. The input data parameters are not supported for expression fields, for example, $serviceVersion.

Support for Ultra Pipelines

Works in Ultra Pipelines.

Snap Views

View TypeView FormatNumber of ViewsExamples of Upstream/Downstream SnapsDescription
InputDocument
  • Min:1
  • Max:1
  • Mapper 
  • Copy
Each document contains Map data for an external ID and records of field and value pairs.
OutputDocument
  • Min:0
  • Max:1
  • Poller
  • JSON Formatter
Each document contains Map data that includes a Job ID, a Batch ID, a URL, and an array of records if it is in Bulk API mode. If it is executed in REST API mode, each document contains input data and a key-value pair of created:false for each successfully-updated record or created:true for each successfully-created record. 
If the Snap is executed in Bulk API mode and a new record is created, the ID field and its value is included in the output data. However, if the Snap is executed in REST API and a new record is created, the ID field is not included in the output data.
Error

Document

  • Min: 1

  • Max: 1

N/A

The error view contains error, reason, resolution and stack trace. For more information, see Handling Errors with an Error Pipeline.

Snap Settings

FieldField TypeField DependencyDescription

Label*


StringNone

Specify a unique name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your Pipeline.

Default Value: Salesforce Upsert
ExampleSalesforce Upsert

Service Version*


String/Expression/SuggestionNone

Specify the version number associated with the Salesforce service that you want to connect to. Alternatively, click the Suggestion  icon to fetch the list of versions and select the desired version.

Default Value52.0 
Example41.0

Batch Size*

Integer/ExpressionNone

Specify the number of records to be processed in a batch.

In Bulk API, this value is allowed to be from 1 through 10,000. Each input document forms one Salesforce record to be upserted. The Snap stores records in memory until the number of records reaches the batch size and sends the request to SFDC in a single batch. Increasing the batch size increases the amount of memory used during the data load. Decreasing the batch size increases the number of API calls against Salesforce.

In REST API, the Snap can upsert only one record per each request regardless of the value you specify in the Batch Size field.

Default Value: 200
Example: 1000

Object Type*
  

String/Expression/SuggestionNone

Specify the name of the Salesforce object or select one from the suggested list.

Default ValueAccount
ExampleAccount

Salesforce API


Dropdown listNone

Set the Salesforce API mode to Bulk API or REST API. The Snap in REST API mode creates one record at a time and returns the results at the output. REST API can be simpler and faster if the number of records to be created is small (a few).

Default Value: Bulk API
Example: REST API

External ID Field*



String/Expression/SuggestionNone

Specify the external ID field that represents the unique externalized key of the object.

The external ID determines the locator of the object on the Salesforce object instead of using the ID field on the object. 


You must select the checkbox, External ID: Set this field as the unique record identifier from an external system, when you create an external ID field in the Salesforce portal.

Default Value:  [None]
Exampleemployee_number__c

Bulk Content Type

Dropdown listNone

Select the content type to be used in Bulk API. Available options are:

  • XML: Data in XML format.

  • CSV: Data in CSV format.

Default Value: XML
Example: CSV

Null Setting with Bulk APICheckboxNone

Select this checkbox to set the nullable fields to null in the Salesforce object if there are null values in the input document. This field works only if you select Bulk API mode in the Salesforce API field.

Default Value: Deselected
Example: Selected


Related Object



String/Expression/SuggestionNone

Enter or select a related parent object. The value in this field does not affect the Snap operation on records in Salesforce. It is provided for the property suggest and the input schema suggest only. 

Default Value: [None]
Example: Account

Related External ID


String/Expression/SuggestionNone

Enter or select an external ID of the selected related parent object. The value in this field does not affect the Snap operation on records in Salesforce. It is provided for the property suggest and the input schema suggest only. 

Default Value: [None]
Example: AccountNumber__c

Apply active assignment rulesCheckboxAppears when you select REST API from the Salesforce API dropdown and when the Object Type is Account, Case, or Lead.

Select this checkbox to apply the active assignment rules for the selected object type (AccountCase, or Lead).

If you deselect this checkbox, active assignment rules are not applied for the selected object type (AccountCase, or Lead).

Default Value: Selected

Bulk API Serial mode


CheckboxNone

Select this checkbox to enable the Bulk API to run in Serial mode.
Deselect this checkbox to enable the Bulk API to run in Parallel mode. This is only relevant to BULK API. 

Default Value: Not selected (Parallel mode)

Standardize Error Output

CheckboxNone

Select this checkbox to enable the Snap to produce error output with Reason, Original, Stack trace and Resolution.
If you deselect this checkbox, the output view displays the input document along with the error message.

Default Value:  Not selected

Pass Through


CheckboxNone

Select this checkbox to pass the input document to the output view under the key 'original'.

If you deselect this checkbox, the input document is not passed and there is no 'original' key in the output document.

Default Value:  Selected

For Bulk APIs, if you select this checkbox and if the Batch size is equal to 1, the input document is passed to the output view under the key original. If the Batch size is greater than 1, the list of input documents is displayed under Records and the input document is not included under the original key.

Snap Execution

Dropdown listNone

Select one of the three modes in which the Snap executes. Available options are:

  • Validate & Execute: Performs limited execution of the Snap, and generates a data preview during Pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during Pipeline runtime.
  • Execute only: Performs full execution of the Snap during Pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.


If you want to get the resulting status for each record to be upserted in Bulk API mode, you must connect a Salesforce Poller Snap after the Salesforce Upsert Snap.


Examples

Upserting Department Record and Associating with an Employee Record

The following example Pipeline demonstrates how to upsert the department record in CSV format and associate that record with an employee record. We also pass null value for a particular field to demonstrate that null values in CSV file format type does not hinder the Pipeline execution.

First, we configure the Sequence Snap to generate a sample set of Department data.


Then, we configure the Mapper Snap to prepare (transform) and pass the department data (input) to the Salesforce Upsert Snap. Note that we pass null value for location, but that does not hinder the Pipeline execution.

Upon validation, the Snap passes the following data to the downstream Salesforce Upsert Snap. Note the null value under location column.

Then, we configure the Salesforce Upsert Snap to upsert the department record into Salesforce. We use the Bulk Content Type as CSV and the API as Bulk API. Note that we configure the Related External ID field to associate the department record with the employee record.

The Snap passes the following batch information to the downstream Salesforce Poller Snap.

We then configure the Salesforce Poller Snap to poll the status of the batch job submitted to Salesforce application from the Salesforce Upsert Snap. Upon validation, the Snap creates the record for department and associates it with the employee record.

Salesforce Poller Snap Configuration

Salesforce Poller Snap Output

Download this Pipeline.

Upserting a new record in a Salesforce object

The following example Pipeline demonstrates how to upsert a new record in a Salesforce object.

First, we configure the Mapper Snap to map the Object record details (that need to be upserted using External ID) to the input view of Salesforce Upsert Snap.

Then, we configure the Salesforce Upsert Snap to update the record (using its External ID) in the Account object.


Upon successful execution, we can see the following output in the Snap's preview.

Downloads

Important steps to successfully reuse Pipelines

  1. Download and import the pipeline into the SnapLogic application.
  2. Configure Snap accounts as applicable.
  3. Provide pipeline parameters as applicable.

  File Modified

File Example_Salesforce_Upsert_CSV_BukAPI.slp

Apr 21, 2021 by Kalpana Malladi

Snap Pack History

 Click to view/expand
Release Snap Pack VersionDateType  Updates

May 2024

main26341

 

Stable

Updated and certified against the current SnapLogic Platform release.

February 2024436patches25626 LatestEnhanced the Salesforce Bulk Create, Bulk Delete, Bulk Query, Bulk Update, and Salesforce Bulk Upsert Snaps to include the complete error details under the original object that contains the copies of the failed input records.
February 2024436patches25192 Latest

Fixed an issue with the Salesforce Mutual Authentication Account where the 8443 port was not used while authorizing the account. Now, the access token request uses the 8443 port for authorizing the Mutual Authentication Account.

Breaking change

Prior to 436patches25192, the Salesforce Mutual Authentication Account supported default Login URLs such as https://login.salesforce.com and https://test.salesforce.com. From 436patches25192, this account no longer supports the default Login URLs—your existing pipelines using the Mutual Authentication Account with the default Login URLs might break.

To prevent this breaking change, you must provide a valid Salesforce Login URL as part of your account configuration.

February 2024main25112 StableEnhanced the Salesforce Bulk Query Snap with expression support for the Include Deleted Records checkbox.
November 2023435patches24747 LatestFixed an issue that caused the input stream to not close properly, which resulted in stale connections.
November 2023435patches24368 Latest

Enhanced the performance of the Salesforce Bulk Query Snap with a new Maximum threads field. This field enables you to download query results simultaneously in multiple threads.

November 2023435patches24006 Latest

Enhanced the Salesforce Read Snap by adding expression enablement to the following checkboxes:

  • Use PK chunking if supported

  • Include Deleted Records

November 2023main23721 StableUpdated and certified against the current SnapLogic Platform release.
August 2023434patches23646 LatestFixed an issue where a long-running pipeline containing the Salesforce Subscriber Snap would suddenly stop responding.
August 2023434patches22537 Latest

Improved the Salesforce Bulk Upsert Snap error messages by limiting the length of the reason displayed with the error.

August 2023main22460 StableUpdated and certified against the current SnapLogic Platform release.
May 2023433patches21367 Latest
  • The Salesforce SOQL Snap now honors the selection of the Match Data Type checkbox when the value entered for Batch Size is greater than 50,000.

  • The Salesforce Read Snap now honors the selection of the Match Data Type checkbox if the Use PK chunking if supported checkbox is also selected.

May 2023

main21015 

Stable

Upgraded with the latest SnapLogic Platform release.

February 2023432patches20586 Latest

Fixed an issue with the Salesforce SOQL and Salesforce Read Snaps where the Match Data Type checkbox selection was not honored if the Salesforce API field was set to Bulk API.

February 2023432patches20393 Latest
February 2023432patches20145 LatestFixed an issue with the Salesforce Read Snap that was causing an error for the Time data type.
February 2023432patches20087  Latest

The Salesforce Create, Update, and Upsert Snaps now include an Apply active assignment rules checkbox so you can control whether to use assignment rules for the selected object

February 2023

432patches20008

 Latest
  • Fixed an issue with the Salesforce Read Snap where using the bulk API request would fail due to column specification.
  • Added support to use PK chunking on any batch size with the bulk API request and to automatically disable PK chunking if it is known that it cannot be done

February 2023main19844 StableUpgraded with the latest SnapLogic Platform release.
November 2022main18944 Stable Upgraded with the latest SnapLogic Platform release.
October 2022430patches18769 Latest
  • The Salesforce Bulk Query Snap now includes the following checkboxes:

    • Match Data Type: Select this checkbox to match the data types of the bulk query job results.

    • Include Deleted Records: Select this checkbox to include deleted records in the query result.

  • The Salesforce Delete Snap in REST API no longer fails with NPE if a new OAuth2 account is used.

  • The Salesforce Read Snap now stops gracefully on a forced stop (without throwing cryptic errors).

  • The Salesforce Update and Salesforce Upsert Snaps no longer fail with the message "Error occurred while executing request to Salesforce.com" when a redirection is needed.

September 2022430patches18125 Latest

The Salesforce Bulk Create, Salesforce Bulk Delete, and Salesforce Bulk Update Snaps are now working as expected without displaying the error Error while processing Data and without returning 301-error while processing the data.

September 2022430patches18036 Latest

The Salesforce Read Snap now correctly parses the 2-byte UTF-8 characters in Windows OS in the PK chunking mode.

August 2022main17386 Stable
  • Updates in Salesforce Subscriber Snap:

    • CometD version upgrade from 5.0.9 to 7.0.6 (latest).

    • The simplified logging provides useful diagnostic information without logging any sensitive data.

    • The Snap asynchronously makes callbacks or listens to the CometD API to identify and respond to specific events.

    • The Snap processes the most recent message so that it can send that replay ID if there is a need to resubscribe. If the server responds with an invalid replay ID, the Snap automatically sets the Replay ID value to -2 to get all available messages.

  • You can select the Null Setting with Bulk API checkbox in the Salesforce Update, Salesforce Create, and Salesforce Upsert Snaps to format null values in the input document.

4.29 Patch

429patches16708 Latest
  • Updates in Salesforce Subscriber Snap:
    • Upgraded the Cometd version from 5.0.9 to the latest 7.0.6 version.
    • Fixed an issue where the Snap reported an error and stopped only at the next resubscribe attempt when it encountered the daily limit exceeded error. Now, the Snap displays the error and stops immediately when it encounters the daily limit exceeded error.
    • Simplified the logging that provides useful diagnostic information without logging any sensitive data.
    • Enhanced the Snap design to make the callbacks or listeners asynchronously by the Cometd API when there is a specific event, and the Snap responds accordingly.
    • Enhanced the tracking of replay ID of the most recent message processed so that Snap can send that replay ID if there is a need to resubscribe. If the server responds that the replay ID is invalid, Snap automatically sets the Replay ID value to -2 to get all available messages.
  • Made the Null Setting with Bulk API checkbox in the Salesforce Update, Salesforce Create, and Salesforce Upsert Snaps visible, to format a null value.

4.29main15993 StableUpgraded with the latest SnapLogic Platform release.
4.28 Patch428patches14355 

Latest

Fixed an issue with Salesforce Snaps where the Service Version could not be retrieved from SFDC due to a blocked URL, failing the Snap execution.

4.28main14627 StableUpgraded with the latest SnapLogic Platform release.
4.27 Patch

427patches14079

 Latest

Fixed an issue with the Salesforce Subscriber Snap where the Snap was unable to re-subscribe to a topic if it did not receive any message for 72 hours —stopped and displayed an error message. With this fix, the Snap automatically sets the Replay ID value to -2 when:

  • the specified Replay ID is invalid or outside the retention window.

  • the most recently received Replay ID for an event is outside the 72-hour retention window.

4.27 Patch427patches13944 LatestFixed an issue with Salesforce accounts, where an account password containing special characters and an empty security token was not properly encoded and the account was not validated.
4.27 Patch427patches13789 Latest

Fixed the following issues with Salesforce Snaps:

  • High memory use due to leaked resources.

  • Hung Pipelines due to blocked threads.

4.27main12833Stable
  • Added Salesforce Mutual Authentication Account to Salesforce Snap Pack that provides an additional layer of security while authentication. Both the client and server authenticate themselves using Client Certificate Authentication. This account is not supported for Salesforce Subscriber and Salesforce Publisher Snaps.

  • Extended the support of Salesforce OAuth2 Account to all the Salesforce Snaps in addition to the Salesforce Bulk Snaps.

  • Revised the name of Salesforce Attachment Download to Salesforce Download Snap. Enhanced this Snap with a new field File Type to support download of attachments from Salesforce by passing Content Data ID in addition to the Attachment ID.

  • Updated the default Salesforce API Service Version to 52.0 for the following Snaps: