config.companyId=<your-company-id> config.userName=<successfactors-username> config.password=<successfactors-password>
SAP SuccessFactors Connector 4.0 - Examples - Mule 4
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.
Before You Begin
To build and run these flows, you need:
-
OpenJDK 8 or 11
-
Anypoint Studio 7.1 or later
-
Mule 4.2.2 or later
-
SuccessFactors Connector 3.x or later
-
SuccessFactors credentials to send OData API requests
-
DataWeave 2.0
Create a Mule Project
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 namesuccessfactors-operations
. -
Click Finish.
Specify Your Credentials
-
In Package Explorer, under
/src/main/resources/
, create a file namedmule-app.properties
. -
Specify your credentials for connecting to SuccessFactors, for example:
-
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.
-
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 as follows:
-
Company ID:
${config.companyId}
-
User Name:
${config.userName}
-
Password:`${config.password}`
-
-
From the Data Center’s Endpoint URL drop-down, select the SuccessFactor’s Web API URL.
The following image shows an example of configuring Basic authentication:
image::sap-successfactors-basic-config.png
-
Click OK.
-
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:
-
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:
XML for Creating a Query
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>
Create an Entry on SuccessFactors Example
The following flow uses the SuccessFactors Create entity operation to create an entry on SuccessFactors:
XML for Creating an Entry
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>
Get Entity by ID Flow
The following flow uses the Get entity by id operation to retrieve an entity by ID:
XML for Getting 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>
Update an Entry on SuccessFactors
The following flow uses the SuccessFactors Update operation to update an entry on SuccessFactors:
XML for Updating an Entry
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>
Delete an Entry on SuccessFactors
The following flow uses the SuccessFactors Delete entity operation to delete an entry on SuccessFactors:
XML for Updating an Entry
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>
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 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="SuccessFactors Configuration" >
<successfactors:basic-connection companyId="${config.companyId}" userName="${config.userName}" password="${config.password}" endpointUrl="https://api4.successfactors.com/odata/v2/"/>
</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"/>
<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>