Getting started Community Training Tutorials Documentation APIs, AI & Tools
config.companyId=<your-company-id> config.userName=<successfactors-username> config.password=<successfactors-password>
These examples show how to create flows to invoke some of SAP SuccessFactor’s standard operations, including how to:
Create a query to query across entities.
Create and update an entry in SuccessFactors.
In Studio, create a new Mule project in which to add and configure the connector:
In Studio, select File > New > Mule Project.
In Project Name, enter a name for your Mule project.
This example uses the name successfactors-operations.
Click Finish.
In Package Explorer, under /src/main/resources/, create a file named mule-app.properties.
Specify your credentials for connecting to SuccessFactors, for example:
config.companyId=<your-company-id> config.userName=<successfactors-username> config.password=<successfactors-password>
Save the file.
Configure a global element to provide the authentication credentials that the connector requires to access the target SuccessFactors system.
At the base of the Studio canvas, click Global Elements.
Select SAP SuccessFactors Config and click Edit.
In the SAP SuccessFactors Configuration window, enter the connection credentials.
From the Data Center’s Endpoint URL drop-down, select the SuccessFactor’s Web API URL.
Click OK.
Click Test Connection to verify the connection to SAP SuccessFactors.
A success message appears.
Create a flow that uses the Query operation to perform queries over entities of a specified type:
In the Mule Palette view, select HTTP > Listener.
Drag Listener to the Studio canvas.
On the Listener configuration screen, optionally change the value of the Display Name field.
Specify /list for the Path field.
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.
On the General tab, specify connection information for the connector.
Click Test Connection to confirm that Mule can connect with the specified server.
Click OK.
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.
In the left pane of the Mule Palette, click Favorites.
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
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:
This is the XML for the Query operation flow:
<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>
The following flow uses the SuccessFactors Create entity operation to create an entry on SuccessFactors:
This is the XML for the Create entity operation flow:
<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>
The following flow uses the Get entity by id operation to retrieve an entity by ID:
This is the XML for the Get entity by id 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
---
{
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>
The following flow uses the SuccessFactors Update operation to update an entry on SuccessFactors:
This is the XML for the Update operation 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>
The following flow uses the SuccessFactors Delete entity operation to delete an entry on SuccessFactors:
This is the XML for the Delete entity operation 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>
Paste this code into your Studio XML editor to quickly load all of the flows for these examples into your Mule app:
<?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>