---
schema_version: "1"
id: 673c64ed7dda80028a9c6eda2ee0f834b12f75c7e95b371a78056792f836c3dc
title: SAP SuccessFactors Connector 5.0 - Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/sap-successfactors-connector/latest/sap-successfactors-connector-examples.md
canonical_url: https://docs.mulesoft.com/sap-successfactors-connector/latest/sap-successfactors-connector-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 49824c9427bfd5b627197b36b01f6ef756bb575d47f1b03622dee5869ba3423b
description: MuleSoft Documentation Site
release: "5.0"
latest: true
---
---
product: SAP SuccessFactors Connector
version: 5.0
is-latest-version: true
---

# SAP SuccessFactors Connector 5.0 - Examples

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

These examples show how to create flows to invoke some of SAP SuccessFactor’s standard operations,
including how to:

- [Create a query](#create-query-flow) to query across entities.

- [Create an entry in SuccessFactors](#create-entry).

- [Get an entity by ID](#get-entity-by-id).

- [Create and update an entry](#update-entry) in SuccessFactors.

- [Delete an entry from SuccessFactors](#delete-entry).

## Prerequisite Steps

1.  [Create a Mule Project](#create-mule-project)

2.  [Specify Your Credentials](#specify-credentials)

3.  [Configure a Global Element](#configure-global-element)

### Create a Mule Project

In Studio, create a new Mule project in which to add and configure the connector:

1.  In Studio, select **File > New > Mule Project**.

2.  In **Project Name**, enter a name for your Mule project.  
    This example uses the name `successfactors-operations`.

3.  Click **Finish**.

### Specify Your Credentials

1.  In **Package Explorer**, under `/src/main/resources/`, create a file named
    `mule-app.properties`.

2.  Specify your credentials for connecting to SuccessFactors, for example:

    config.companyId=<your-company-id> config.userName=<successfactors-username>
    config.password=<successfactors-password>

3.  Save the file.

### Configure a Global Element for the Connector

Configure a global element to provide the authentication credentials that the connector requires to
access the target SuccessFactors system.

1.  At the base of the Studio canvas, click **Global Elements**.

2.  Select **SAP SuccessFactors Config** and click **Edit**.

3.  In the SAP SuccessFactors Configuration window, enter the connection credentials.

4.  From the **Data Center’s Endpoint URL** drop-down, select the SuccessFactor’s Web API URL.

5.  Click **OK**.

6.  Click **Test Connection** to verify the connection to SAP SuccessFactors.

    A success message appears.

## Create the Query Operation Flow

Create a flow that uses the **Query** operation to perform queries over entities of a specified
type:

1.  In the **Mule Palette** view, select **HTTP > Listener**.

2.  Drag **Listener** to the Studio canvas.

3.  On the **Listener** configuration screen, optionally change the value of the **Display Name**
    field.

4.  Specify `/list` for the **Path** field.

5.  Click the plus sign (**+**) next to the **Connector configuration** field to configure a global
    element that can be used by all instances of HTTP **Listener** in the app.

    1.  On the **General** tab, specify connection information for the connector.

    2.  Click **Test Connection** to confirm that Mule can connect with the specified server.

    3.  Click **OK**.

6.  In the **Mule Palette** view, select **SAP SuccessFactors**, then select the **Query** operation
    and drag it on to the Studio canvas to the right of the **Listener** operation.

7.  In the left pane of the **Mule Palette**, click **Favorites**.

8.  Select **Transform Message** and drag it on to the Studio canvas to the right of the **Query**
    operation.  
    The **Transform Message** component transforms the data structure and format to produce the
    output the connector expects, in this case, `application/json`:

    %dw 2.0 output application/json
    ---

    payload

9.  Add a **Logger** component to the end of the flow that takes a `payload` (or `#[payload]`) as
    the message.

The following image shows the SuccessFactors **Query** operation flow:

![Mule flow using an HTTP Listener source, SuccessFactory Query operation, Transform Message, and Logger components](/mulesoft/current/en-us/sap-successfactors-connector/latest/_images/sap-successfactors-query-flow.png)

### XML for Creating a Query

This is the XML for the **Query** operation flow:

```xml
<flow name="Query" >
        <http:listener doc:name="Listener"
        config-ref="HTTP_Listener_config2" path="/list"/>
        <successfactors:query entitySetName="User" doc:name="Query" config-ref="SuccessFactors_Configuration" >
		</successfactors:query>
		<ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <logger level="INFO" doc:name="Logger" message="#[payload]"/>
    </flow>
```

### Test the Flow

To test the flow:

1.  Run the app.

2.  Open a browser.

3.  Navigate to `http://localhost:8081/list`.

## Create an Entry on SuccessFactors Example

The following flow uses the SuccessFactors **Create entity** operation to create an entry on
SuccessFactors:

![Mule flow using an HTTP Listener source, SuccessFactors Create entity operation, Transform Message, and Logger components](/mulesoft/current/en-us/sap-successfactors-connector/latest/_images/sap-successfactors-ops-1.png)

### XML for Creating an Entry

This is the XML for the **Create entity** operation flow:

```xml
<flow name="Create-Entry">
           <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/createVendor"/>
           <ee:transform doc:name="Transform Message">
               <ee:message >
                   <ee:set-payload ><![CDATA[%dw 2.0
   output application/java
   ---
   {
       vendorCode: "XYZ123ABC",
       effectiveStartDate: "2018-07-08T00:00:00"  as DateTime,
       effectiveStatus: "I"
   }]]></ee:set-payload>
               </ee:message>
           </ee:transform>
           <successfactors:create-entity doc:name="Create entity"
	   config-ref="SuccessFactors_Configuration" entitySetName="VendorInfo"/>
           <ee:transform doc:name="Transform Message" >
               <ee:message >
                   <ee:set-payload ><![CDATA[%dw 2.0
   output application/json
   ---
   payload]]></ee:set-payload>
               </ee:message>
           </ee:transform>
           <logger level="INFO" doc:name="Logger" message="#[payload]"/>
       </flow>
```

### Test the Flow

To test the flow:

1.  Run the app.

2.  Open a browser.

3.  Navigate to `http://localhost:8081/create`.

## Get Entity by ID Flow

The following flow uses the **Get entity by id** operation to retrieve an entity by ID:

![Mule flow using an HTTP Listener source, SuccessFactors Get entity by id operation, Transform Message, and Logger components](/mulesoft/current/en-us/sap-successfactors-connector/latest/_images/sap-success-factors-get-entity-by-id.png)

### XML for Getting an Entity by ID

This is the XML for the **Get entity by id** flow:

```xml
<flow name="Get-Entity-by-Id">
           <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/getById"/>
           <ee:transform doc:name="Transform Message">
               <ee:message>
                   <ee:set-payload><![CDATA[%dw 2.0
   output application/java
   ---
   {
   	effectiveStartDate: attributes.queryParams.effectiveStartDate as DateTime,
   	vendorCode: attributes.queryParams.vendorCode
   }]]></ee:set-payload>
               </ee:message>
           </ee:transform>
   		<successfactors:get-entity-by-id entitySetName="VendorInfo" doc:name="Get entity by id"
		config-ref="SuccessFactors_Configuration" />
           <ee:transform doc:name="Transform Message">
               <ee:message >
                   <ee:set-payload ><![CDATA[%dw 2.0
   output application/json
   ---
   payload]]></ee:set-payload>
               </ee:message>
           </ee:transform>
           <logger level="INFO" doc:name="Logger" message="#[payload]"/>
       </flow>
```

### Test the Flow

To test the flow:

1.  Run the app.

2.  Open a browser.

3.  Navigate to `http://localhost:8081/getById`.

## Update an Entry on SuccessFactors

The following flow uses the SuccessFactors **Update** operation to update an entry on
SuccessFactors:

![Mule flow using an HTTP Listener source, SuccessFactors Create entity and Update operations, Transform Message, and Logger components](/mulesoft/current/en-us/sap-successfactors-connector/latest/_images/sap-successfactors-create-and-update.png)

### XML for Updating an Entry

This is the XML for the **Update** operation flow:

```xml
<flow name="Update" >
        <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/update"/>
        <ee:transform doc:name="Transform Message" >
            <ee:message>
                <ee:set-payload><![CDATA[var nowTime = (now()  as String {format:"yyyy-MM-dd"} ++ "T00:00Z[UTC]") as DateTime
---
{
	effectiveStartDate: nowTime ,
	mdfSystemExternalCode:"TV60" ++ uuid(),
	cust_effectiveStatus:"A"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:create-entity entitySetName="cust_VendorInfo" doc:name="Create entity"
        config-ref="SuccessFactors_Configuration" />
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[output application/java
var nowTime = (now()  as String {format:"yyyy-MM-dd"} ++ "T00:00Z[UTC]") as DateTime
---
{
	effectiveStartDate: payload.effectiveStartDate,
	mdfSystemExternalCode: payload.mdfSystemExternalCode,
	cust_effectiveStatus: payload.cust_effectiveStatus
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:update entitySetName="cust_VendorInfo" doc:name="Update"
        config-ref="SuccessFactors_Configuration"/>
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <logger level="INFO" doc:name="Logger" message="#[payload]"/>
    </flow>
```

### Test the Flow

To test the flow:

1.  Run the app.

2.  Open a browser.

3.  Navigate to `http://localhost:8081/update`.

## Delete an Entry on SuccessFactors

The following flow uses the SuccessFactors **Delete entity** operation to delete an entry on
SuccessFactors:

![Mule flow using an HTTP Listener source, SuccessFactors Create entity and Delete entity operations, Transform Message, and Logger components](/mulesoft/current/en-us/sap-successfactors-connector/latest/_images/sap-successfactors-delete.png)

### XML for Updating an Entry

This is the XML for the **Delete entity** operation flow:

```xml
<flow name="Delete-Entry" >
        <http:listener doc:name="Listener"
        config-ref="HTTP_Listener_config" path="/delete"/>
        <ee:transform doc:name="Transform Message" >
            <ee:message>
                <ee:set-payload><![CDATA[var nowTime = (now()  as String {format:"yyyy-MM-dd"} ++ "T00:00Z[UTC]") as DateTime
---
{
	effectiveStartDate: nowTime ,
	mdfSystemExternalCode:"TV60" ++ uuid(),
	cust_effectiveStatus:"A"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:create-entity entitySetName="cust_VendorInfo" doc:name="Create entity"
        config-ref="SuccessFactors_Configuration" />
        <ee:transform doc:name="Transform Message" >
            <ee:message>
                <ee:set-payload><![CDATA[output application/java
var nowTime = (now()  as String {format:"yyyy-MM-dd"} ++ "T00:00Z[UTC]") as DateTime
---
{
	effectiveStartDate: payload.effectiveStartDate,
	mdfSystemExternalCode: payload.mdfSystemExternalCode,
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:delete-entity entitySetName="cust_VendorInfo" doc:name="Delete entity"
        config-ref="SuccessFactors_Configuration" />
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <logger level="INFO" doc:name="Logger" message="#[payload]"/>
    </flow>
```

### Test the Flow

To test the flow:

1.  Run the app.

2.  Open a browser.

3.  Navigate to `http://localhost:8081/delete`.

## XML for SuccessFactor Operations

Paste this code into your Studio XML editor to quickly load all of the flows for these examples into
your Mule app:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
      xmlns:successfactors="http://www.mulesoft.org/schema/mule/successfactors" xmlns:http="http://www.mulesoft.org/schema/mule/http"
      xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/successfactors http://www.mulesoft.org/schema/mule/successfactors/current/mule-successfactors.xsd">
    <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
        <http:listener-connection host="0.0.0.0" port="8081" />
    </http:listener-config>
    <successfactors:config name="SuccessFactors_Configuration" doc:name="SAP SuccessFactors Configuration">
        <successfactors:oauth-connection clientId="${config.clientId}" userId="${config.userId}"
            companyId="${config.companyId}" keyStore="${config.keyStorePath}" storePassword="${config.storePassword}"
            certificateAlias="${config.certificateAlias}" tokenUrl="https://hcm4preview.sapsf.com/oauth/token" endpointUrl="${config.endpointUrl}"
            defaultQueryParams="#[[{ 'key': 'asOfDate', 'value': vars.currDate as String }]]"
            connectionTimeout="5" connectionTimeoutUnit="MINUTES">
        </successfactors:oauth-connection>
    </successfactors:config>
    <configuration-properties doc:name="Configuration properties" file="mule-app.properties" />
    <http:listener-config name="HTTP_Listener_config1" doc:name="HTTP Listener config" >
		<http:listener-connection host="localhost" port="8081" />
	</http:listener-config>
	<http:listener-config name="HTTP_Listener_config2" doc:name="HTTP Listener config" >
		<http:listener-connection host="localhost" port="8081" />
	</http:listener-config>
	<flow name="Query" >
        <http:listener doc:name="Listener" config-ref="HTTP_Listener_config2" path="/list"/>
        <set-variable value='#[now() as Date {format: "yyyyMMdd"}]' doc:name="Set Variable" variableName="currDate"/>
        <successfactors:query entitySetName="User" doc:name="Query" config-ref="SuccessFactors_Configuration" >
		</successfactors:query>
		<ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <logger level="INFO" doc:name="Logger" message="#[payload]"/>
    </flow>

    <flow name="Create-Entry" >
        <http:listener doc:name="Listener"
        config-ref="HTTP_Listener_config" path="/create"/>
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[var nowTime = (now()  as String {format:"yyyy-MM-dd"} ++ "T00:00Z[UTC]") as DateTime
---
{
	effectiveStartDate: nowTime ,
	mdfSystemExternalCode:"TV60" ++ uuid(),
	cust_effectiveStatus:"A"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:create-entity doc:name="Create entity"  config-ref="SuccessFactors_Configuration" entitySetName="cust_VendorInfo"/>
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <logger level="INFO" doc:name="Logger" message="#[payload]"/>
    </flow>

    <flow name="Get-Entity-by-Id" >
        <http:listener doc:name="Listener"
        config-ref="HTTP_Listener_config" path="/getById"/>
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
{
	userId: "PSADMIN"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:get-entity-by-id entitySetName="User" doc:name="Get entity by id"
        config-ref="SuccessFactors_Configuration" />
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <logger level="INFO" doc:name="Logger" message="#[payload]"/>
    </flow>
    <flow name="Update" >
        <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/update"/>
        <ee:transform doc:name="Transform Message" >
            <ee:message>
                <ee:set-payload><![CDATA[var nowTime = (now()  as String {format:"yyyy-MM-dd"} ++ "T00:00Z[UTC]") as DateTime
---
{
	effectiveStartDate: nowTime ,
	mdfSystemExternalCode:"TV60" ++ uuid(),
	cust_effectiveStatus:"A"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:create-entity entitySetName="cust_VendorInfo" doc:name="Create entity"
        config-ref="SuccessFactors_Configuration" />
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[output application/java
var nowTime = (now()  as String {format:"yyyy-MM-dd"} ++ "T00:00Z[UTC]") as DateTime
---
{
	effectiveStartDate: payload.effectiveStartDate,
	mdfSystemExternalCode: payload.mdfSystemExternalCode,
	cust_effectiveStatus: payload.cust_effectiveStatus
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:update entitySetName="cust_VendorInfo" doc:name="Update"
        config-ref="SuccessFactors_Configuration"/>
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <logger level="INFO" doc:name="Logger" message="#[payload]"/>
    </flow>


    <flow name="Delete-Entry" >
        <http:listener doc:name="Listener"
        config-ref="HTTP_Listener_config" path="/delete"/>
        <ee:transform doc:name="Transform Message" >
            <ee:message>
                <ee:set-payload><![CDATA[var nowTime = (now()  as String {format:"yyyy-MM-dd"} ++ "T00:00Z[UTC]") as DateTime
---
{
	effectiveStartDate: nowTime ,
	mdfSystemExternalCode:"TV60" ++ uuid(),
	cust_effectiveStatus:"A"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:create-entity entitySetName="cust_VendorInfo" doc:name="Create entity"
        config-ref="SuccessFactors_Configuration" />
        <ee:transform doc:name="Transform Message" >
            <ee:message>
                <ee:set-payload><![CDATA[output application/java
var nowTime = (now()  as String {format:"yyyy-MM-dd"} ++ "T00:00Z[UTC]") as DateTime
---
{
	effectiveStartDate: payload.effectiveStartDate,
	mdfSystemExternalCode: payload.mdfSystemExternalCode,
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <successfactors:delete-entity entitySetName="cust_VendorInfo" doc:name="Delete entity"
        config-ref="SuccessFactors_Configuration" />
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <logger level="INFO" doc:name="Logger" message="#[payload]"/>
    </flow>
</mule>
```

## See Also

- [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)

- [Salesforce Help](https://help.salesforce.com)
