
Hello All,
Greetings for the Day!!
Fetching delta records in Success Factors can be straightforward when dealing with a single entity using filters and the lastModifiedDateTime field. However, the process becomes more complex when multiple entities are involved, each with its own lastModifiedDateTime field. Traditional methods, such as using properties or XSLT mapping, can be cumbersome and may lead to inefficient full loads from the system.
To address this challenge, I have developed a Groovy script that simplifies the process of retrieving delta records from multiple entities in Success Factors using the OData API. This script ensures efficient data retrieval without the complexity of traditional methods.
In this blog, I will walk you through the code and demonstrate how to use it to fetch delta records from various entities in Success Factors.
Step 1: Declare Properties in the Content Modifier
The first step is to declare the necessary properties in the Content Modifier. Below is an image showing the configuration of the Content Modifier:
Content Modifier Configuration
Explanation of Properties
Full_Dump
Timestamp
ThisRun
LastRun
Initial_Timestamp
Need_Initial
From_Date
To_Date
Troubleshooting
Declare necessary properties. The Content Modifier is connected to the Router.
Step 2: Router Condition
Next, you need to set up a Router Condition to store the Initial Timestamp as the last execution time when the Need_Initial property is passed as true. This ensures that the integration can handle initial loads and subsequent delta loads effectively. The Expression Type in the Router will be NON XML, and the condition will be ${property.Need_Initial} = 'true'.
When you remove the Need_Initial property, the integration will perform a normal run and will be passed through the Default Route.
Set up a Router Condition. Initial Run Path connects to Write Variable; Normal Run connects to Groovy Script.
Step 3: Configuring Write Variable
In this step, you will configure the Write Variable to store the Initial_Timestamp property with the current timestamp into the Last_Execution property. This ensures that the last execution time is updated correctly for future runs.
Write Variable Configuration:
This step ensures that the integration accurately tracks the last execution time, enabling efficient delta record fetching in subsequent runs.
Connect Write Variable to End Message.
Step 4: Groovy Script Explanation
Here's the Groovy script that helps fetch delta records from multiple entities in Success Factors:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
def Message processData(Message message) {
// Retrieve properties from the message
def pMap = message.getProperties();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = new Date();
// Pull the data stored in Write Variable as Property
def lastRun = pMap.get("LastRun");
def fromDate = pMap.get("From_Date");
def toDate = pMap.get("To_Date");
def fullDump = pMap.get("Full_Dump");
def qFromDate;
def qToDate;
// Determine the query date range
if (fullDump == "true") {
// Set to a very early date for full dump
qFromDate = "1900-01-01T00:00:00Z";
qToDate = dateFormat.format(date);
} else {
// Use provided fromDate or lastRun if fromDate is not provided
qFromDate = fromDate != "" ? fromDate : lastRun;
// Use provided toDate or current date if toDate is not provided
qToDate = toDate != "" ? toDate : dateFormat.format(date);
}
// Construct the query filter
def stb_lastRun = new StringBuffer();
def lastModifiedFields = [
"lastModifiedDateTime",
"userNav/lastModifiedDateTime",
"employmentNav/lastModifiedDateTime",
"employmentNav/personNav/lastModifiedDateTime",
"employmentNav/personNav/personalInfoNav/lastModifiedDateTime"
];
// Create conditions for each lastModifiedDateTime field
def conditions = lastModifiedFields.collect { field ->
"($field ge datetimeoffset'$qFromDate' and $field lt datetimeoffset'$qToDate')"
}.join(" or ");
// Append conditions to the query filter
stb_lastRun.append(conditions);
def val = stb_lastRun.toString();
// Set the constructed query filter as a property in the message
message.setProperty("QueryFilter", val);
return message;
}
Script Breakdown
Imports and Initial Setup:
Fetching Properties:
Determining Query Dates:
Constructing the Query Filter:
Setting the Query Filter:
(Optional) Code Modification to Fetch Delta Records from Other Entities of Success-factors:
We have added the paths of EmpJob, EmpEmployment, User, PerPerson, PerPersonal to fetch the delta records from these entities. If you want to add other entities, kindly add the path in the part of the code shown below:
def lastModifiedFields = [
"lastModifiedDateTime",
"userNav/lastModifiedDateTime",
"employmentNav/lastModifiedDateTime",
"employmentNav/personNav/lastModifiedDateTime",
"employmentNav/personNav/personalInfoNav/lastModifiedDateTime"
];
Connect Groovy Script to Request Reply.
Step 5: Using Request Reply & Connecting with the Receiver
Request Reply:
Configure Connections:
Select Entities and Fields:
Add Filter Condition:
Connect Request Reply to Process Call.
Step 6: Process Call Configuration in Main Integration Process
The Process Call is used to update the LastRun date to ensure accurate tracking of the last execution time. It also checks if the run is for troubleshooting by verifying the Troubleshooting property, allowing for specific handling or logging during debugging. Configuration involves selecting the Local Integration Process, such as a Troubleshooting Process.
Set up Local Integration Process to handle troubleshooting & to Update Last Run property.
Step 7: Configuring Local Integration Process
In this step, we configure the Local Integration Process to check if the run is for troubleshooting. This involves using a router to verify the Troubleshooting property. If the Troubleshooting property is set to true, the integration will consider this as a test run or debugging is taking place, and it will not update the Last_Execution date. If it is blank, the process will update the Last_Execution date to ensure accurate tracking of the last execution time.
Step 8: Router Condition in Troubleshooting Process
Next, you need to set up a Router Condition to verify if the Troubleshooting property is passed as true. If it is true, the integration will pass through Route 1. The Expression Type in the Router will be NON XML, and the condition will be ${property.Troubleshooting} = 'true'.
If the Troubleshooting property is not passed as true, the integration will pass through Route 2 (False), which is the default route. In this case, it will store the ThisRun timestamp into the Last_Execution property, ensuring that the last execution time is updated correctly.
True Route connects to End; False Route connects to Write Variable.
Step 9: Configuring Write Variable in Troubleshooting Process
In this step, you will configure the Write Variable to store the ThisRun property with the current timestamp into the Last_Execution property. This ensures that the last execution time is updated correctly for future runs.
Write Variable Configuration:
This step ensures that the integration accurately tracks the last execution time, enabling efficient delta record fetching in subsequent runs.
Connect Write Variable to End.
After performing all the steps mentioned above, this is how your integration should look like. We have started it with the Start Timer, but this can vary based on your specific requirements. The integration is designed to handle both initial and subsequent runs efficiently, ensuring accurate data retrieval and processing. By following the outlined scenarios, you can customise the integration to meet your specific needs, whether it's for a full load, date range, or delta records.
As this blog focuses on fetching delta records, we haven't configured the Target System, which could be FTP or any third-party system. You might need to structure the data according to the target system using Message Mapping or XSLT Mapping. Additionally, you may need to handle exceptional subprocesses and process successful and failed responses from the third-party system. Ensure to add the Process Call at the end so that it only stores the run when the integration is successfully completed.
Integration Deployment Configuration:
Go Live Configuration
Date Range Configuration
Scenario 3: Full Dump Configuration
Note: Always save and deploy the integration after changing its configuration.
Additional Note: If you are using a Start Timer in your integration, make sure to change it to run once, or it will provide the output as scheduled.
Conclusion
In this blog, we explored how to efficiently fetch delta records from multiple entities in SuccessFactors using the OData API. By using a combination of Groovy scripts, Content Modifiers, and Router Conditions, we can streamline the process and avoid the complexities of traditional methods. This approach ensures that we only retrieve the necessary data, improving the efficiency and performance of our integrations.
By following these steps, you can effectively manage delta records in SuccessFactors, ensuring that your data is always up to date without overloading the system. If you have any questions or need further assistance, feel free to reach out. Happy integrating!
Best Regards,
Rasesh Thakkar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
9 | |
7 | |
5 | |
4 | |
4 | |
3 | |
3 | |
2 | |
2 |