Salesforce Adapter Guide for SAP CPI
Salesforce Adapter Guide for SAP CPI
Contents
1 Introduction .............................................................................................................. 3
1.1 Coding Samples .............................................................................................................. 3
1.2 Internet Hyperlinks ......................................................................................................... 3
2 Salesforce Integration................................................................................................ 3
2.1 Introduction ................................................................................................................... 3
2.2 Salesforce Adapter ......................................................................................................... 4
2.2.1 Features ............................................................................................................................................4
2.3 Architecture Overview .................................................................................................... 5
3 Supported Operations and Versions ........................................................................... 7
3.1 REST API ......................................................................................................................... 7
3.2 REST Bulk API ................................................................................................................. 8
3.3 REST Place Order API ...................................................................................................... 8
4 Authentication .......................................................................................................... 9
5 Adapter Configuration ..............................................................................................10
5.1 Connection Tab ............................................................................................................ 10
5.2 Processing Tab.............................................................................................................. 11
5.2.1 REST API......................................................................................................................................... 12
5.2.2 Place Order API ............................................................................................................................. 17
5.2.3 Bulk API ......................................................................................................................................... 20
1
Salesforce Adapter Guide
10 References................................................................................................................57
10.1 Initialize OAuth 2.0 in Salesforce ................................................................................... 57
10.2 Composite Instructions Salesforce................................................................................. 61
2
Salesforce Adapter Guide
1 Introduction
This is the official guide for the Salesforce Adapter for SAP Cloud Platform Integration (SAP
CPI). This guide covers all relevant information for integration developers to start working
with the Salesforce Adapter. The adapter supports an extensive set of operations
supported by the Salesforce API.
Please read this guide carefully before using the Salesforce adapter.
Any software coding and/or code lines/strings ("Code") included in this documentation are
only examples and are not intended to be used in a productive system environment. The
Code is only intended to better explain and visualize the syntax and phrasing rules of
certain coding. We do not warrant the correctness and completeness of the Code given
herein.
The documentation may contain hyperlinks to the Internet. These hyperlinks are intended
to serve as a hint about where to find related information. We do not warrant the
availability and the correctness of this related information or the ability of this information
to serve a particular purpose.
2 Salesforce Integration
2.1 Introduction
Salesforce is a SaaS Cloud solution that covers four main topics; Marketing, Sales, Orders,
and Support. Salesforce Cloud supports sales, marketing, and customer support in both
B2B and B2C contexts. It helps track customer information and interactions in one place,
automates complex business processes, keeps all information up to date, nurtures leads,
and tracks the effectiveness of marketing campaigns.
• Manage order flow to Salesforce from your SAP and non-SAP backend applications,
3
Salesforce Adapter Guide
In the next sections, we will discuss the available options and the adapter features.
From a high-level perspective, the Salesforce adapter has a few key features that will be
discussed in the next sections.
2.2.1 Features
• Querying and searching: In addition to all the operations that the Salesforce
adapter offers, the adapter allows you to query data from your Salesforce system
using SOQL and SOSL queries.
• Secure authentication with OAuth 2.0: Every REST call between Salesforce and SAP
CPI is secured by the OAuth 2.0 industry-standard protocol for authorization.
• Dynamic configuration with headers and properties: The Salesforce adapter gives
you the freedom to assign dynamic values to its different properties. It allows you
to refer to dynamic parameters using SAP CPI exchange headers and properties.
• Processing large sets of data: With Bulk support, the Salesforce adapter is
optimized for loading or deleting large sets of data. Using batches many records
can be processed asynchronously.
• Supports for XML & JSON: XML and JSON are fully incorporated throughout the
adapter, while the REST Bulk API supports CSV and ZIP files. Furthermore, the
Salesforce adapter also processes binary content from your Salesforce system,
more specifically the Document and Attachment object as part of the REST – Get
Blob operation.
• Pretty print: It is possible to “pretty print” the XML and JSON message payloads
returned by Salesforce to improve readability by formatting the data structure.
• Support for various Salesforce versions: Salesforce releases few versions of its API
every year. The Salesforce adapter lets you integrate with the Salesforce API
version of your choice. At the time of this publishing, the Salesforce adapter
supports up to Salesforce API Version 48.0.
• Query and XSD Eclipse plug-in: The Eclipse Query plug-in enables you to create
correct and specific SOQL and SOSL queries. The Eclipse XSD plug-in helps you
generate all necessary up-to-date messages XSD’s for your specific Salesforce
version and custom objects.
4
Salesforce Adapter Guide
• Full integration support for Custom Objects and Fields: In addition to supporting all
the standard Salesforce objects, the adapter integrates with all the custom objects
in Salesforce.
• Support for latest API version: The adapter supports the latest Salesforce API
version (Version 48), which was released in Spring 2020.
• Support nested structures in the CRUD operations: This feature supports the
references that link nested SObjects to a main SObject in the XSD Generation plug-
in. This allows the user to map referenced SObjects in the structure. For example,
the Account XSD contains the referenced subobjects Account, ReportsTo, and
Owner.
From a technical perspective, the Salesforce adapter can be used as a receiver adapter
and the SAP Cloud Integration acts as the initiator of the calls. To schedule calls toward
Salesforce, the user can follow the Scheduler steps within the integration flow.
Figure 2.1 shows how the Salesforce adapter can be used in a simple request-reply
scenario and gives a high-level representation of how the adapter works. Various
operations can be used in the adapter – such as query data, delete, update, upsert, or
create an SObject, etc. The different adapter operations and their configuration are
explained in Section 5.
The Request-Reply Step can use the Salesforce adapter as show in Figure 2.1. This adapter
is responsible to connect and interact with Salesforce and invoke its different operations.
The Eclipse Plug-in, which is delivered together with the adapter, can also be used to help
the user generate the XSDs of the different entities or business objects that are part of
the Salesforce tenant.
The XSDs generated by the Eclipse Plug-in can be imported in an Integration Flow and
used in mappings. You can, for instance, use it in the mapping in front of the Request-
Reply Step. This way, you can create the correct XML request message to create or update
an SObject in Salesforce (see the Mapping Step on the left side of the Request-Reply
Step). Similarly, you can use the XSDs to create a mapping to handle the response
message sent by Salesforce.
5
Salesforce Adapter Guide
• The XSD Generator helps you generate up-to-date XSDs for your Salesforce
SObjects for different operations (create, delete, update, etc.). This makes
mappings to other system’s message types a straightforward step. For the
Salesforce plug-in and XSD Generator configuration please refer to the Salesforce
Adapter and Plug-in Installation Guide.
• The Query Editor assists you in creating valid SOQL or SOSL queries. With these
queries, you can get the best out of the REST, and REST Bulk API. To read more
about the Salesforce Eclipse plug-in, refer to the document Salesforce Adapter and
Plug-in Installation Guide.
Figure 2.2 shows at which stage of the SAP CPI integration flow, the Salesforce adapter
can be used and where the XSD Generator and the SOSL or SOQL Query Editor are used.
6
Salesforce Adapter Guide
• REST API
A short description of each one of these REST APIs are presented in the next sections.
The REST API is selected by default and lets you integrate with Salesforce using either
XML or JSON formats. The integration is done securely by utilizing the OAuth protocol for
authenticating your REST calls. The REST API enables you to access the full data model
of Salesforce and execute CRUD operations and many more. Note that these operations
generally handle single SObject records as input.
However, if you have many records to process, you can opt for the Bulk API (explained in
detail in Section 3.2) which is optimized for large sets of data. The following operations
are currently supported in the adapter’s REST API Category:
• Metadata – All
• Metadata – Basic
• Metadata – Comprehensive
7
Salesforce Adapter Guide
To get a description of the purpose of each of the above operations and how to configure
them, refer to Section 5.2.1.
The Bulk API is specifically designed to load or update large sets of data into a Salesforce
organization. With this API, it is possible to query, insert, update, upsert, or delete many
records asynchronously by submitting batches for Salesforce to process in the background.
The following operations are currently supported in the adapter:
• Batch – Create
• Batch – Get
• Job – Abort
• Job – Close
• Job – Create
• Job – Get
To get a description of the purpose of each of the above operations and how to configure
them, refer to Section 5.2.3.
The Place Order API lets you access your organization’s order and contract data
programmatically. This is a composite API that supports the creation of contract, order,
order product, and custom object records in a single call. The following operations are
currently supported in the adapter:
8
Salesforce Adapter Guide
• Contract – Get
• Order – Get
4 Authentication
The Salesforce adapter supports OAuth 2.0. The adapter makes use of common security
artifacts in SAP Cloud Platform Integration. You are required to use Secure Parameter and
User Credentials to safely store OAuth tokens, user-password combinations, and secrets.
These security artifacts can then be accessed in the adapter using aliases.
The Salesforce adapter uses the OAuth 2.0 Salesforce Autonomous Client
type. The adapter uses a Basic Authentication flow which requires a Salesforce username
and password to connect to the Salesforce tenant data. In addition to the username and
password, you are also required to provide the so-called Salesforce app credentials.
These app credentials consist of a client id and client secret. The diagram in Figure
4.1 explains the process that is used in the background to connect to Salesforce. With the
access token that is returned from the authorization server, the Salesforce adapter can
make different requests to Salesforce resources.
Figure 4.1 SAP Cloud Platform Salesforce adapter authenticating as OAuth 2.0 Autonomous Client
9
Salesforce Adapter Guide
5 Adapter Configuration
This section describes the different parameters that can be configured for the Receiver
Adapter. This adapter has the Connection and Processing tabs. Each one of these will be
explained in the next sections.
The Connection tab contains parameters that define how to connect to and how to
authenticate against Salesforce.
As can be seen in Figure 5.1, the connection tab contains the following fields:
• Address: This specifies the recipient's endpoint URL. By default, the URL
[Link] is used. But you can change it based on your scenario.
For Salesforce production environments: [Link]
For Sandbox environments: [Link]
• Basic Credential Name: Specifies the name of the User Credentials artifact that
contains the credentials for basic authentication. This refers to the username-
password pair used to login in Salesforce. You need to create this as a Security
artifact of type User Credential. Then refer to it here in the adapter.
• Security Token Alias: Specifies the name of the Secure Parameter artifact that
contains the security token needed to connect to Salesforce. This property
enables the system to fetch the security token from Keystore for authentication.
This field can be omitted if your IP has been whitelisted on Salesforce.
• OAuth Credential Name: Specifies the name of the User Credentials artifact that
contains the Salesforce’s OAuth Consumer key-client secret pair. This
property enables the system to fetch the security token from Keystore for
authentication.
• Connection Timeout (in ms): Specifies the connection timeout in milliseconds. The
timeout allows you to control the wait time until the connection is established.
• Response Timeout (in ms): Specifies the response timeout in milliseconds. The
timeout allows you to control the wait time until the message is received.
10
Salesforce Adapter Guide
For more details on how to retrieve details of the Security token, Consumer key-client
secret pair, refer to Section 10.1.
The Processing tab contains all the operation configurations for the selected Salesforce
API. An example configuration for the operation Salesforce Object – Create is shown in
Figure 5.2.
The different properties of the adapter shown in Figure 5.2 are described below:
• Type: Specifies the category of the API to be used to interact with Salesforce.
Possible values include REST, REST Bulk, and REST Place Order. These different
API types were explained in Section 3.
• API Version: The API Version specifies the version of the Salesforce API. It ranges
from version 20.0 up to the latest Salesforce version supported by the adapter. At
the time of publishing this document, Version 48 is the latest one.
• Operation: To access and exchange data with Salesforce, you can choose one of
the provided operation options. Here you specify the type of action you want to
execute in Salesforce. Section 5.2.1 dives into all the different operations and assist
you in deciding what operation to use for your integration scenario.
• Payload Format: This field specifies the format of the request message to be sent
to and response to be returned from Salesforce. Possible values include
Application/XML and Application/JSON. Note that the default value is
Application/XML.
• Salesforce Object: Select the name of the object in Salesforce to operate on.
Example: accounts, Lead, Order, etc. You can select Custom in case any custom
SObject is involved.
• Pretty Print: Select the Pretty Print checkbox to nicely format the XML payload and
improve its readability.
11
Salesforce Adapter Guide
The REST API supports 15 operations to retrieve or send data to Salesforce. These
operations are categorized into five groups known as Salesforce Object, Metadata, SOQL,
SOSL, and Others.
There are a set of common fields that are often used across different operations in the
salesforce adapter. These common fields are described below:
• Operation: To access and exchange data with Salesforce, you can choose one of
the operation options listed in the dropdown.
• External ID Name: Refers to the name of a custom field of the SObject which is
configured as an external ID. This is an alternative way to identify a Salesforce
Object record based on a unique identifier provided by an external system (other
than Salesforce).
• External ID Value: Refers to the value of the External ID Name field. For example,
in a scenario where an SAP ERP system needs to synchronize master data with
Salesforce, one might use SAPReferenceNumber in Salesforce (as External ID
Name) and 10005210032 as (External ID Value) to identify that record in
Salesforce based on the SAP identifier.
• SOQL Query: Specifies the SOQL Query to be executed in Salesforce. SOQL stands
for Salesforce Object Query Language and is an adaptation of the well-known SQL
query language. A simple SELECT ID, Name FROM Account will give you all the ID
and Name for all Account records in Salesforce. For more advanced queries use the
SOQL Query Editor showcased in detail in Section 7.1.
• SOSL Search: Specifies the SOSL Search to be executed in Salesforce. SOSL stands
for Salesforce Object Search Language and is used to construct text-based search
queries against the search index. You can search text, email, and phone fields for
multiple objects, including custom objects. An example SOSL is FIND {Bakery*}
RETURNING account (industry, ID, billingStreet, name). Section 7.2 explains how
to use the SOSL Search Editor to get the most out of your SOSL Salesforce
searches.
• Filter Fields: Specifies the fields of the SObject that needs to be returned as part
of the result of a query toward Salesforce. Without any field specified in this
property, all fields of the SObject will be returned. For example, instead of getting
back all the fields for a specific Salesforce Object, the operation Salesforce Object
– Get can be narrowed down by applying a filter for only ID, name, and industry.
In the next sections, we will explain each operation of the REST API and what they can
be used for.
12
Salesforce Adapter Guide
This operation retrieves a list of information about each REST API version currently
available.
This operation retrieves a list of resources available for the specified API version.
This operation retrieves a list of available objects for your Salesforce tenant. This operation
also returns the Salesforce org encoding, as well as the maximum batch size permitted in
queries.
This operation retrieves metadata for a specified Salesforce object. The below table shows
an example configuration of this operation.
Example Configuration
This operation retrieves all the metadata for a specified Salesforce object.
This operation retrieves a record in Salesforce and its properties. The below table shows
an example configuration of this operation. Also, note in this example the configuration of
specifying the names (ID, name) in the fields to be returned (in the property named List
of Fields).
13
Salesforce Adapter Guide
Example Configuration
This operation creates a new record of a specified Salesforce Object. The request payload
provides the property and field values in the request data. The response body will contain
the unique identifier (ID) of the created record if the call is successful.
This operation updates a Salesforce Object record. The request payload contains the
property values that are needed to update a record in Salesforce based on a specific record
ID. The below table shows an example configuration of this operation.
Example Configuration
This operation deletes a Salesforce Object record. The operation requires the unique
identifier of the Salesforce record to be specified.
This operation retrieves details of a Salesforce Object record using the value of a specified
external ID. This operation differs from Salesforce Object – Get because the External ID
14
Salesforce Adapter Guide
should be specified instead of the Salesforce record ID. This is shown in the example
configuration below.
Example Configuration
This operation deletes a record using the value of a specified External ID. Therefore, the
External ID should be specified instead of the Salesforce ID of the record.
This operation allows you to execute powerful SOQL queries for retrieving Salesforce data.
When using this operation, it is possible to filter the records to be returned in the response
from Salesforce. For example, you could return the IDs and the names of all the Accounts
based in France with more than one billion yearly revenue. The SOQL query returns all the
records in a single response. It is however possible to return part of the remaining records
using an identifier. For more details on how to achieve this, please refer to the operation
SOQL Execute Query for More Results. Furthermore, you can use the SOQL Query Editor
(which is provided in the Eclipse Plugin) to build specific and complex queries. This is
specified in Section 7.1. The following table shows an example configuration.
15
Salesforce Adapter Guide
Example Configuration
This operation retrieves the query results that were not returned in the original SOQL –
Execute Query response using a Next Records URL. SOQL - Execute Query for More Results
is therefore an extension of the previous operation. This operation exists because in some
cases the result of a query can generate a lot of data that can not all be returned within
one response payload. In such a case, a URL is returned in the SOQL - Execute Query.
This URL can then be used in the Execute Query for More Results operation. The table
below shows an example configuration.
Example Configuration
This operation supports a SOSL query to search for useful information in Salesforce. The
Salesforce Object Search language lets users search using strings throughout the entire
Salesforce tenant and acts as an alternative for the SOQL query. Users can utilize the
SOSL Search Editor to build complex queries. For details on how to use the SOSL Search
editor in the Eclipse Plugin, see Section 7.2. The table below shows an example
configuration.
16
Salesforce Adapter Guide
Data Insert
This operation allows you to create a composite call with a request body that contains
various individual calls like upsert and read actions on multiple SObjects. The Composite
operation supports the usage of multiple SObject records and multiple SObject types in
one operation. Imagine an integration scenario where you would like to create one account
and two contacts within the same call to Salesforce. In such a case the composite operation
can be used. A more detailed example scenario can be found in Section 9.4. The table
below shows an example configuration.
Example Configuration
The Place Order API supports 8 operations that retrieve or push data to Salesforce. These
operations are categorized into three groups known as Account, Contract, and Order. The
configuration for each operation can differ in terms of dynamic setting and whether the
API expects a request body or returns a response body.
There are a set of common fields that are often used across different operations in the
Place Order API. These common fields are described below:
• Order ID: The unique identifier (ID) of the Order that is being processed. Similar
to Salesforce Object ID, this is the unique identifier that can be found in the last
part of the URL in the Order record view in the Salesforce Console.
• Contract ID: The unique identifier (ID) of the Contract that is being processed.
Within the context of the place order API, Contracts act as the parent Salesforce
Object and Orders as the child Salesforce Object.
17
Salesforce Adapter Guide
• Filter Name: Contains the name of the child object field to be used for filtering
purposes. For illustration, imagine that you would like to filter all orders that below
to a contract and that have a particular statuscode.
• Filter Value: Contains the value of the child object field to be used for filtering
purposes. Together, the Filter Name and Filter Value can help to retrieve specific
fields of an Order or Contract. An example is provided in Section [Link].
This operation creates contract-based orders in Salesforce. The table below shows an
example configuration.
Example Configuration
This operation can create multiple orders with their order items (also known as order
products) for an existing account.
This operation creates an order with order products for an existing contract. The table
below shows an example configuration.
Example Configuration
18
Salesforce Adapter Guide
This operation queries a contract based on a filter criteria specified in the Contract ID,
Filter Name, and Filter Value field. The table below shows an example configuration.
In this example, we are filtering orders that have the StatusCode equal to “Activated” with
the contract with ID “80036000000dq8E”.
Example Configuration
This operation retrieves the details of a Contract record in Salesforce based on its ID. Note
that it also returns its child orders, order products, and custom objects.
This operation adds order products to an existing order. It is required to specify the order
ID.
This operation queries orders based on filter criteria. The table below shows an example
configuration.
Example Configuration
19
Salesforce Adapter Guide
This operation retrieves the details of an order record in Salesforce based on its ID. Note
that it also returns its order products and child custom objects.
The Bulk API supports 12 operations to retrieve or push large sets of data. It uses the
concepts of jobs and batches. A job works as a container that holds one or more batches.
Each batch can contain 10.000 records. Note that the inserted batches need to conform
to the settings of the job.
Figure 5.3 depicts the relationship between a Job, Batches, and the processing of data.
After the batches are added to a specific job, the included records will be processed in
Salesforce. Besides being able to create, abort, close, retrieve jobs, it is also possible to
retrieve the status and the results with specific operations that this adapter provides.
There are a set of common fields that are often used across different operations in the
Bulk API. These common fields are described below:
• Content Type: Specifies the file content of the batches. You can select from CSV,
JSON, XML, ZIP CSV, ZIP JSON and ZIP XML. This implies that a batch can be
created in CSV, JSON, XML, and its ZIP equivalent.
• Result ID: represents the unique identifier for the Result in the response to the
batch result list request. For Bulk API Query operations, you can use this Result ID
to retrieve the results of a Bulk Query.
Each one of the operations of the Bulk API is explained in the next sections.
This operation creates a REST Bulk Job. In the request message, you can specify the
properties of the job, which acts as a specification for future attached Batches. The table
below shows an example configuration.
20
Salesforce Adapter Guide
Example Configuration
This operation retrieves all details for an existing job. The table below shows an example
configuration.
Example Configuration
This operation aborts an existing job. When a job is identified and aborted, no more
records are processed. If changes to data have already been committed, they aren’t rolled
back.
This operation closes the job after it has finished processing. When a job is identified and
closed, no more batches can be added to it.
Get information about all batches in a specific job by executing this operation.
This operation adds a new batch to an existing job. The request body contains a list of
records to be processed. The table below shows an example configuration.
21
Salesforce Adapter Guide
Data Insert
Data Insert
This operation retrieves a batch request. It is also possible to retrieve the original request
which was used to initiate the Batch.
This operation retrieves the results for a specific Batch. Because Batches are processed
asynchronously, you need this operation to see the results after Batch processing has been
completed. Note that the content type of the result matches the one of the request. This
means that in case the batch is a CSV file, the response will also be in CSV format.
Alternatively, you can monitor a Bulk API batch in the Salesforce console.
22
Salesforce Adapter Guide
Example Configuration
When a batch query has completed processing records you can retrieve the results with
this operation, using the Result ID that you get back from the operation Batch Query –
Get Result IDs. Alternatively, you can monitor a Bulk API batch in Salesforce.
Example Configuration
This operation retrieves a list of Result IDs. These Result IDs can then be used in the Batch
Query – Get Result operation to retrieve the actual results. Alternatively, you can view the
Result IDs in the Salesforce console.
23
Salesforce Adapter Guide
The XSD Generator (configuration details in Section 7.3) helps in two ways. First, it
generates the XSDs that you might want to use in mappings in your integration scenario.
Following our example, the XSD will include elements/properties of the SObjects.
Assuming that you are performing a Create operation in Salesforce, using the correct
request XSD as the target of the mapping before the request-reply will help you create a
valid input message (payload) towards Salesforce.
The XSDs obtained from the Eclipse Plugin can help to provide a good understanding of
the request message that the various Salesforce operations expect as well as the response
messages that you can expect from Salesforce.
This section illustrates the use of dynamic values in the adapter property. It depicts a
simple Salesforce Object – Get operation configuration using a dynamic header reference.
1. You need to use a content modifier before the Request-Reply step in your
Integration flow, and this content Modifier should create a Message Header. The
name of the Message Header is the name you need to refer to in the Salesforce
Adapter. Any name is allowed here. Note that it is also possible to use properties
instead of a header to achieve the same. In this example, we use the Constant
type and fill in the Salesforce Object ID as a value.
24
Salesforce Adapter Guide
2. The Salesforce Receiver adapter (which is linked to the Request-Reply step) needs
to refer to this header by using ${[Link]}. To refer to a property, a syntax
similar to ${[Link]} should be used. In our example, we can refer to the
AccountID header using the syntax ${[Link]}, as can be seen in
Figure 6.3. The Salesforce Adapter will automatically replace this reference with
the ID 0013600000xU52T.
Figure 6.3 Adapter Specific tab for Salesforce Object - Get operation
The SOQL Query Editor helps build and test well-formatted queries in the Salesforce Object
Query Language. It supports the building of queries for the Rest and Bulk API. Depending
on the selected API, different functionality is supported according to the Salesforce
documentation. The offset functionality, for example, can be used in the Rest API, but not
in the Bulk API. The Query Editor is limited to queries within one object since relationships
and joins have not been implemented. The SOQL Query Editor is the first tab in the
Salesforce CPI Adapter Tool perspective, see Figure 7.1.
The following steps show how to create a query with the SOQL Query Editor and describe
the sections and elements of the editor.
25
Salesforce Adapter Guide
Objects and their subsequent fields can be selected in the left component of the SOQL
Query Editor, as shown in Figure 7.2. At the bottom of the component is the progress bar
that runs when data is retrieved from salesforce and prepared for display.
26
Salesforce Adapter Guide
1. Select the API version in the Version dropdown. The version is synchronized
between the different tabs. If a version is selected in another tab, this will be
automatically selected here.
2. Select the API for which you want to create a query. Choices are Rest or Bulk.
3. Optional: Search for the object you want to create a query for, using the
Search SObject… field.
4. For example, type “acc” and the list below will only show objects with that letter
combination such as “account” or “access”.
5. Click on the arrow in front of an object to load all the fields of the object.
Alternatively, the box in front of the object can be selected, this will load and select
all fields of that object.
6. Select the objects or specific fields you want to create a query for. The selected
fields will be visible in the SELECT section.
The component on the top right of the SOQL Query Editor enables you to set different
query options. The different syntax elements have their own section, labeled accordingly;
see Figure 7.3.
27
Salesforce Adapter Guide
o In the table, you can choose to format fields to local settings by selecting
the box. If a field is formatted, it is possible to give it an alias.
o Date functions are available for date/DateTime fields. This column enables
formatting the field, for example, a calendar year or month. Click on the
arrow to show the dropdown with available options and select.
• The FROM section shows which Salesforce Object is selected. This cannot be
changed in this section; it is changed dynamically by selecting fields from a
different object in the Objects and Fields component.
• In the USING SCOPE section, the scope of the query can be set. The default scope
is “everything”, without this being indicated in the query.
• In the WHERE section, the field and operator can be selected for the statement.
Depending on the selected field, the input changes accordingly.
o For picklists fields, the input is a dropdown with all available options.
o For DateTime fields, the input will split up into two parts: the first part being
a calendar to select the date from; the second an input field for a time.
Alternatively, you can choose to use time literals by ticking the box. The
input will change into a dropdown with time literals.
Select the NULL box if you want a query for records without value.
Additional WHERE statements can be added by pressing the plus sign on the right.
This will add a new row to create an extra statement. New rows will be preceded
with a dropdown to select AND/OR. To remove a row, click the minus sign on the
right of the row.
See
Figure 7.4 Overview of the WHERE section
• The GROUP BY section enables grouping query results. A field can be selected to
group by. Optionally you can choose to group by rollup or group by cube, to include
subtotals in the query.
28
Salesforce Adapter Guide
HAVING is a sub-section of GROUP BY. Here you can select a having statement
for the grouping. This section functions in the same way as the WHERE section
described above.
• In the ORDER BY section, the field to sort on can be selected. The default order is
ascending, selecting the DESC box puts the query results descending order.
Additionally, records without an entry for the selected fields can be placed at the
bottom of the query result by selecting the box NULLS LAST.
• The LIMIT section allows setting the limit of query results returned from a query.
This is only available for the REST and Bulk API.
• In the OFFSET section, it is possible to set the starting row of the returned result
set. This is only available for the REST API.
7.1.3 Results
The component located at the bottom right allows you to test the created query. See
Figure 7.5 for an overview of the component.
• The text field on the left shows the created query. This query cannot be edited
manually; it can only be changed by the settings in the other components.
29
Salesforce Adapter Guide
• Press Run Query to test the query and see if the results are as expected. It will
take some time to process this request, the button will indicate that the query is
running, and return to the original state when the query is finished.
• The Query Result tab on the right will display the results in a table.
• If the query is not valid, the Syntax Check tab on the right can be consulted. This
displays additional information: the message and error code of the response.
• If the results are satisfactory, the query can be copied for use in the
Salesforce CPI Adapter. You can either press the “Copy Query” button that copies
the query to the clipboard, or select the query and copy it manually.
• An XSD for the query result can be generated by pressing the “Generate XSD”
button. The generated XSD will pop up on a new screen. Here you can choose to
either cancel or save the XSD. The generated XSD can be used to map the query
results in an integration scenario.
The SOSL Query Editor helps build and test well-formatted searches in the Salesforce
Object Search Language. It supports the building of searches for the Rest API. In a search
query, you can look for data in multiple objects, for example in both account and contact.
The SOSL Query Editor is the second tab in the Salesforce CPI Adapter Tool perspective,
as shown in Figure 7.6. The following steps show how to create a query with the SOSL
Query Editor and describe the sections and elements of the editor.
Objects and fields of objects can be selected in the left component of the SOSL Query
Editor. At the bottom of the component, there is a progress bar that will run when data is
retrieved from salesforce and prepared for display. This component is identical to the one
in the SOQL Query Editor described above.
30
Salesforce Adapter Guide
1. Select the API version in the “Version” dropdown. The version is synchronized
between the different tabs. If a version is selected in another tab, this will be
automatically selected here.
2. The selection of an API is disabled, SOSL can only be used for the Rest API.
3. Optional: Search for the object you want to create a query for using the “Search
SObject…” field.
4. For example Type “acc” and the list below will only show objects with that letter
combination such as those with “account” or “access” in the name.
5. Click on the arrow in front of an object to load all the fields of the object.
Alternatively, the box in front of the object can be selected, this will load and select
all fields of that object.
6. Select the objects or specific fields you want to create a search for.
The component on the top right of the SOSL Query Editor enables you to set different
search options. The different syntax elements have their own section, labeled accordingly.
See Figure 7.7.
• In the FIND section, the user can type what they are looking for such as name,
number, or partial string. An entry is required for a search query.
• The IN section shows which fields are used for the search. The default setting
is “ALL FIELDS”. The dropdown allows for the selection of other options such as
“NAME” and “EMAIL FIELDS”.
31
Salesforce Adapter Guide
o In the table, you can choose to format fields to local settings by ticking the
box. If a field is formatted it is possible to give it an alias.
o Select toLabel to translate the search result into the user’s language.
• In the ORDER BY section, the field to sort on can be selected. Default order is
ascending, selecting the DESC box puts the query results descending order.
Additionally, records without entry for the selected field can be placed at the bottom
of the query result by ticking the box NULLS LAST.
• The LIMIT section allows setting the limit of the search result set that is returned.
• In the OFFSET section, it is possible to set the starting row of the returned result
set.
• In the WHERE section, the field and operator can be selected for the statement.
Depending on the selected field, the input changes accordingly.
o For picklists fields, the input is a dropdown with all available options.
o For DateTime fields, the input will split up into two parts: the first a calendar
to select the date from; the second an input field for a time. Alternatively,
you can choose to use time literals by ticking the box. The input will change
into a dropdown with time literals.
Select the NULL box if you want a query for records without value.
Additional WHERE statements can be added by pressing the plus sign on the right.
This will add a new row to create an extra statement. New rows will be preceded
with a dropdown to select AND/OR. To remove a row, click the minus sign on the
right of the row.
7.2.3 Results
The component located at the bottom right allows you to test the created query.
See Figure 32 for an overview of the component.
32
Salesforce Adapter Guide
• The text field on the left shows the created query. This query cannot be edited
manually; it can only be changed by the settings in the other components.
• Press Run Query to test the query and see if the results are as expected. It will
take some time to process this request, the button will indicate that the query is
running, and return to the original state when the query is finished.
• The Query Result tab on the right will be display the results in a table.
• If the query is not valid, the Syntax Check tab on the right can be consulted. This
displays additional information: the message and error code of the response.
• If the results are satisfactory, the query can be copied for use in the
Salesforce CPI Adapter. You can either press the “Copy Query” button that copies
the query to the clipboard, or select the query and copy it yourself.
An XSD for the query result can be generated by pressing the “Generate XSD” button. The
generated XSD will pop up in a new screen. Here choose to either cancel or save the XSD.
The generated XSD can be used to map the query results in an integration scenario.
33
Salesforce Adapter Guide
Figure 7.9 XSD Generator overview with the request XSD as output
4. Only for Bulk API, Batch - Create: Select the operation of the Job in the
Job Operation dropdown.
5. Select a Salesforce Object if applicable. The Search SObject… field can be used
to filter the list of SObjects in the list below.
6. Click Save XSD to save the displayed XSD. Switch tabs to save the corresponding
response/request.
REST API
34
Salesforce Adapter Guide
Bulk API
35
Salesforce Adapter Guide
The requests in a composite call are called subrequests. All subrequests are executed in
the context of the same user. In a subrequest’s body, you specify a reference ID that
maps to the subrequest’s response. You can then refer to the ID in the URL or body fields
of later subrequests by using a JavaScript-like reference notation.
You can specify whether an error in a subrequest causes the whole composite request to
roll back or just the subrequests that depend on it. You can also specify headers for each
subrequest.
2. Click on Get SObjects to retrieve a list of SObjects for the specific Salesforce tenant.
5. Click Save XSD to save the displayed XSD. Switch tabs to save the corresponding
response/request.
This component works with Salesforce API version 43.0 and later. Please find a detailed
explanation of the Aggregation/Composite operation in Section 9.4.
Figure 7.10 XSD Generator Aggregation/Composite overview with part of the selection on the left and resulting request XSD
on the right side
8 Support
In case of issues or errors, change the Log level of your integration flow to Traces. This
can be done in Cloud Platform Integration via the Monitor > Manage Integration Content
page. An example of such a configuration can be seen in Figure 8.1.
36
Salesforce Adapter Guide
The Trace Log level enables the collection of more traces that can be used to effectively
understand the problem. These traces can also be used in a ticket.
The next section discusses few issues that you might encounter and possible solutions for
them.
8.1 SSLHandshakeException
Error Message:
[Link]: [Link]:
PKIX path building failed:
[Link]: unable to find valid
certification path to requested target, cause:
[Link]: unable to find valid
certification path to requested target.
Possible Solution: This error generally means that in the Keystore of SAP CPI, an entry for
the root certificate of Salesforce is missing. At the time this document is published,
Salesforce expects a DigiCert Global Root certificate.
Error Message:
Possible Solution: This error generally indicates that one of the security artifacts used in
the Connection tab in the adapter does not exists. Ensure that the artifact used in the
connection tab exists as a Security Material.
37
Salesforce Adapter Guide
Error Message:
Possible Solution: This error generally indicates that the SOQL or SOSL Query format is
wrong. The Plugin can help format the Query. Possible solutions include replacing the ‘&’
sign to connect queries with _and_, or putting your query inside of the following text:
RAW({advanced query}).
Error Message:
[Link]:
[Link]: Cannot produce target
element /request/entry/name. Queue has not enough values in context. Target
xsd requires a value for this element, but target field mapping does not produce
one. Probably the xml-instance is not valid to the source xsd, or the target field
mapping does not fulfill the requirement of the target xsd., cause:
[Link].tf7
Possible Solution: This error generally indicates that the mapping requires a missing
mandatory value in the message body you are sending when creating or updating an
instance of an entity in Salesforce.
In this section, three commonly used scenarios will be explained to show the use of the
adapter and the Eclipse Plug-in.
Requirements:
• Salesforce tenant
• Salesforce adapter
All these scenarios start with the creation of an Integration Package and adding a new
Integration Flow. Find these initial steps below.
38
Salesforce Adapter Guide
1. Launch SAP CPI Web application by accessing the URL provided by SAP.
2. If you are a new user, choose Signup.
3. If you have user credentials, choose Login.
Data Insert
39
Salesforce Adapter Guide
1. Choose Artifacts, select Add and select Integration Flow to add a new
integration flow as an artifact.
2. Select Create and enter the required data.
Data Insert
Create X
Name Test Process Integration
Description <Description>
Sender Sender
Receiver Receiver
This scenario explains the synchronization of data via the Upsert capability in Salesforce.
It replicates a message coming from a sender system via a Timer component and a
Content Modified component and will either create or update respective records in receiver
system Salesforce.
40
Salesforce Adapter Guide
4. Click on Events, and select the Timer, connect Timer and End Message.
41
Salesforce Adapter Guide
6. Add a message containing Account data to the Content Modifier to replicate the
message coming from the sender. In this case, the message has the XML format.
7. Add an exchange property with the reference ID value (ID used for correlation of
the record between the two systems), for example ReferenceID.
2. In Eclipse, select the XSD Generator, select the REST API, and then select the
Salesforce Object – Upsert with External ID Operation. Select Account under
the Salesforce Objects, and save the corresponding Request XSD file.
42
Salesforce Adapter Guide
3. Select the Message Mapping in the integration flow, and then select Create and
create a name.
4. Upload the XSD Request file as the Target Message. The Source Message should
be configured with the XSD of the message of the sender.
Figure 9.11 Salesforce Object – Upsert with External ID – Account as Target XSD in message mapping
43
Salesforce Adapter Guide
5. Map the two message structures from Source to Target using the Message Mapping
element.
1. Add a Request Reply to the integration flow after the Message Mapping.
2. Select Request Reply and choose the arrow to drag the pointer to Receiver.
Then, select the Salesforce Adapter.
3. Select REST as the Type in the Processing tab of the Salesforce Adapter. Select
Salesforce Object – Upsert with Exernal ID as the Operation, and Account
as the Salesforce Object. Specify ${[Link]} in the External ID
Value field, and ReferenceID__c in the External ID Name field.
44
Salesforce Adapter Guide
4. Select the Connection tab in the Salesforce Adapter and enter the required data
into fields Basic Credential Name and OAuth Credential Name. Next to this
provide the Security Token by referring to a secure parameter.
1. Add another Message Mapping after the Salesforce Receiver Adapter and
connect them. In Eclipse, save the corresponding Response XSD (as generated
before together with the Request XSD) and add it as the Target Message and
click OK.
2. Select Message Mapping and then select the arrow to drag it to the End
Message.
45
Salesforce Adapter Guide
4. Click on Events, and select the Timer, connect Timer and End Message.
46
Salesforce Adapter Guide
1. Add a Request Reply to the integration flow after the Message Mapping.
2. Select Request Reply and choose the arrow to drag the pointer to Receiver.
Then, select the Salesforce Adapter.
3. Select the Connection tab in the Salesforce Adapter and enter the required data
into fields Basic Credential Name and OAuth Credential Name. Next to this
provide the Security Token by referring to a secure parameter.
47
Salesforce Adapter Guide
4. In the Processing tab select for operation SOQL – Execute Query and Payload
Format: Application/XML.
1. In Eclipse, select the SOQL Query Editor, select the REST API. Select Account
under the Salesforce Objects, and click on Copy Query.
2. Copy the query into the SOQL Query field in the Salesforce Adapter.
48
Salesforce Adapter Guide
1. In Eclipse, click on Generate XSD and Save XSD to create and save the XSD for
the response mapping for the create SOQL query.
2. Add a Message Mapping.
3. Use the generated XSD as Source Message (and for test purposes also as Target
Message) and click OK.
4. Select Message Mapping and then select the arrow to drag it to the End
Message.
49
Salesforce Adapter Guide
The Composite operation supports using multiple SObject records and multiple SObject
types in one operation. It is applicable in an integration scenario where you would like to
create one account and two contacts within the same message to Salesforce.
4. Click on Events, and select the Timer, connect Timer and End Message.
50
Salesforce Adapter Guide
6. Add a message containing Composite data to the Content Modifier, to replicate this
message coming from the sender. In this case, the message has the XML format.
Find an example of a start of a composite message below.
51
Salesforce Adapter Guide
3. Select the Message Mapping in the integration flow, and then select Create and
create a name.
52
Salesforce Adapter Guide
4. Upload the XSD Request file as the Target Message (and for test purposes also
as the Source Messge).
5. Map the two messages structures from Source to Target using the Message
Mapping element.
1. Add a Request Reply to the integration flow after the Message Mapping.
53
Salesforce Adapter Guide
2. Select Request Reply and choose the arrow to drag the pointer to Receiver.
Then, select the Salesforce Adapter.
3. Select REST as the Type in the Processing tab of the Salesforce Adapter. Select
Salesforce Object – Composite as the Operation.
4. Select the Connection tab in the Salesforce Adapter and enter the required data
into fields Basic Credential Name and OAuth Credential Name. Next to this,
provide the Security Token by referring to a secure parameter.
54
Salesforce Adapter Guide
2. Depending on whether the external IDs mentioned in the individual calls exist or
not, the Account and/or Contact SObjects will be updated or created in Salesforce
with the data present in the request message.
9.5 Monitor and Test Integration Flow in SAP CPI with Salesforce
1. After deploying an integration flow select and choose the Monitor tab to see
whether the integration flow started successfully.
2. Select the started integration flow in Manage Integration Content to see details.
This provides an overview of all the messages and IFlows that successfully started
or gave an error.
3. You can add a Groovy Script after to log the body payload in the Message Monitor.
Select the Groovy Script, click Create and add the following script:
import [Link];
import [Link];
if(messageLog != null){
[Link]("Salesforce Payload Response:", body, "application/xml");
}
return message;
}
55
Salesforce Adapter Guide
1. After deploying an integration flow select and choose the Monitor tab to see
whether the integration flow started successfully.
3. Here the message status, properties, logs and attachment will be visible.
56
Salesforce Adapter Guide
10 References
10.1 Initialize OAuth 2.0 in Salesforce
1. The Login URL is the login URL that is used by the authorization server of
Salesforce. In the online documentation of Salesforce this URL is specified as
[Link] This link directs the Salesforce adapter to the login
page of Salesforce to authorize.
2. The Basic Credential Name refers to an alias of a Username and Password
combination stored in the SAP Cloud Platform Integration Secure Store. This is the
exact Username and Password you use to login at the Salesforce console.
3. Open Monitor tab in SAP Cloud Platform.
4. Select Security Material in the section Manage Security Material.
5. Select Add, select User Credentials and enter a Name which should be the same
as the Basic Credential Name you configure in the Salesforce adapter
Authentication tab. In User and Password fields fill in the username and password
you use to log in to the Salesforce console. Select Deploy.
57
Salesforce Adapter Guide
6. For the Security Token and OAuth Credentials an app needs to be create in the
Salesforce tenant. Login to your Salesforce console and select Setup.
7. On the left panel in the Build overview, select Create, select Apps and select New
for the Connected Apps section.
8. In the next screen fill in basic details such as App Name, API Name and Contact
Email. In the API (Enable OAuth Settings) select Enable OAuth Settings.
9. Select Enable OAuth Settings.
10. Unselect Enable for Device Flow.
11. Fill in a Callback URL.
12. Select Use digital signatures.
13. Set Selected OAuth Scopes to Full access (full).
14. Select Require Secret for Web Server Flow.
15. Unselect Include ID Token.
16. Unselect Enable Asset Tokens.
17. Select Save to complete the creation of the app.
58
Salesforce Adapter Guide
18. In the next overview and when you select the specific connect app, you can find
the Client ID and Client Secret, in the respective Consumer Key and Consumer
Secret fields.
19. Deploy this Client ID and Client Secret as User Credentials similarly as done in
step 2 of Section 10.1. Create a new Credential Name and fill in Client ID as
User and Client Secret as Password.
20. In case the IP address of SAP Cloud Platform Integration is not whitelisted in the
settings of Salesforce you need a Security Token. In case you have not received
the security token via email yet, you can direct to My Settings select Personal
and select Reset My Security Token to receive a new security token.
59
Salesforce Adapter Guide
21. To deploy the Security Token, select Security Material in the section Manage
Security Material. Select Add and then select Secure Parameter.
22. Fill in the Secure Parameter Name which should match the Security Token
Name used in the Salesforce adapter. Fill in the Security Token in the Secure
Parameter field and select Deploy.
23. Every required security detail is successfully deployed for a secure OAuth 2.0
Autonomous Client connection for the Salesforce adapter. It is important that the
names configured for Basic Credential Name, Security Token and OAuth
Credential Name match the names of the deployed artefacts in the SAP secure
stores as described in the steps above. Now the authentication part is completed,
the Salesforce adapter can be configured for every specific Salesforce integration
scenario.
60
Salesforce Adapter Guide
Executes a series of REST API requests in a single call. You can use the output of one
request as the input to a subsequent request. The response bodies and HTTP statuses of
the requests are returned in a single response body. The entire series of requests counts
as a single call toward your API limits.
The requests in a composite call are called subrequests. All subrequests are executed in
the context of the same user. In a subrequest’s body, you specify a reference ID that
maps to the subrequest’s response. You can then refer to the ID in the url or body fields
of later subrequests by using a JavaScript-like reference notation.
For example, the following composite request body includes two subrequests. The first
creates an account and designates the output as refAccount. The second creates a contact
parented under the new account by referencing refAccount in the subrequest body.
1. {
2. "compositeRequest" : [{
3. "method" : "POST",
4. "url" : "/services/data/v50.0/sobjects/Account",
5. "referenceId" : "refAccount",
6. "body" : { "Name" : "Sample Account" }
7. },{
8. "method" : "POST",
9. "url" : "/services/data/v50.0/sobjects/Contact",
10. "referenceId" : "refContact",
11. "body" : {
12. "LastName" : "Sample Contact",
13. "AccountId" : "@{[Link]}"
14. }
15. }]
16. }
You can specify whether an error in a subrequest causes the whole composite request to
roll back or just the subrequests that depend on it. You can also specify headers for each
subrequest.
61
The External ID in Salesforce acts as a unique identifier that links records between Salesforce and external systems such as SAP. It allows for seamless integration by referencing an external system's unique field, enabling Salesforce operations to identify and synchronize records based on this identifier rather than internal Salesforce IDs. This facilitates data integration and consistency across systems by leveraging field-based identification rather than internal IDs .
SOQL (Salesforce Object Query Language) allows for constructing queries that retrieve specific fields and filter records using complex conditions, making it ideal for precise data retrieval. SOSL (Salesforce Object Search Language), on the other hand, enables text-based searches across multiple objects and fields, such as email or phone fields, which is beneficial for broader searches. Each language, although similar, serves distinct purposes depending on the data retrieval needs .
The Salesforce Adapter in SAP CPI simplifies interaction with Salesforce APIs by providing a configurable mechanism to perform operations such as create, update, delete, and query Salesforce records. It offers a RESTful communication method, allows mapping of messages from SAP to Salesforce data structures, and supports secure authentication using OAuth tokens. By abstracting API complexities, it streamlines integration and automates interactions, reducing manual effort and enhancing integration simplicity .
SAP CPI enhances Salesforce integration scenarios by supporting composite operations that allow multiple SObject records and types to be processed within a single transaction. This means that related records like an account and its contacts can be created or updated simultaneously, reducing transaction times and ensuring data consistency. The use of composite operations streamlines complex integration processes by minimizing API calls and efficiently handling related data within the same message flow .
When executing a SOQL - Execute Query operation, considerations include ensuring the query is optimized to avoid performance issues, such as large dataset retrieval. Limits on response size and field filtering should be applied where possible to improve efficiency. Additionally, understanding the correct hierarchy and relationships of the Salesforce objects involved is crucial for cohesive query results, and considering Governor Limits within Salesforce is essential to avoid surpassing the platform's limits .
The Bulk API is preferred for operations involving large data sets due to its design for handling a high volume of records. It divides data into batches and processes them in jobs, allowing for efficient insertion, update, or deletion of thousands of records at once. This is particularly advantageous when needing to meet large-scale data integration requirements quickly and efficiently .
The Salesforce Object - Get operation retrieves a record's details using the Salesforce ID, allowing for the extraction of specific fields configured in the operation settings. It is significant for retrieving precise data points needed for processing or integration purposes, ensuring that only relevant and necessary information is accessed, thereby optimizing data handling and performance efficiency .
Filter fields in Salesforce Object queries allow for precise control over the data returned, reducing memory usage and increasing query efficiency by limiting the results to only necessary fields. However, over-reliance on filters might lead to overly complex queries that can become difficult to manage and may limit flexibility if data requirements change .
The Salesforce Object - Upsert with External ID operation uses the specified external ID value to determine whether to create a new record or update an existing one. If the external ID value matches an existing record, the record is updated with the specified field values. If no match is found, a new record is created with those values .
The Pretty Print option in the Salesforce Adapter enhances data readability by formatting JSON or XML outputs with line breaks and indentations, making it easier to read and debug. This is particularly useful during development or troubleshooting, as it allows developers to more quickly understand the data structure and identify any issues without the noise of compressed text formats. However, it could slightly increase payload sizes, so the necessity should be evaluated based on specific troubleshooting requirements .