How to query deleted employee data records using API

Context/Background

Employee data can be deleted by employee themselves, their managers or HR Ops in Employee Central based on the permission granted to them.This blog explains data for which portlets can be deleted and how those deleted data records can be retrieved for cases where there is a requirement to sync those deleted records in the downstream systems.The permission to delete these portlets is mostly driven by RBP and its organization specific settings.

Deletion use cases

There are various scenarios where an employee can delete personal data. For example, consider a scenario where the employee has updated his/her personal email id and personal cell number in the morning, these data sent down to a downstream system via an automated interface which picks only “delta” data( i.e employee data changes since last interface run).However, the employee later realizes that the data he/she maintained earlier is NOT correct, so instead of correcting it, he/she deletes the entire personal email/phone row and enters a new record with correct information this time. So next time when the interface runs, it should send both the deleted email/cell as well as new email/cell detail.

Another example is, the employee enters a “home” address which is sent to the downstream system. But then the employee realizes that the address should be “mailing” address instead.employee deletes the home address and inserts a new record for mailing address.So in SF database, 2 records would exist, home address tagged as DELETED and mailing as “INSERT”.

The below table gives a generalized view whether data for a portlet can be deleted or not ( please note, for some of the portlets it depends upon the EC permission/configuration used)

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

Data for foundation table are generally not deleted instead delimited. Also as of 2017 Q3 release, I don’t think there is any API which can extract deleted foundation table records.

How the deleted records can be retrieved?

Deleted records from SAP can be retrieved either by audit report ( not part of this blog) or by using SF API CompoundEmployee ( in Delta mode).

In order to extract deleted data, in the CompoundEmployee API query, one needs to use queryMode = Delta along with other parameters like “last_modified_on“, “fromDate” and “toDate” as shown below ( one can use the query mode “periodDelta” as well but this is not explained in this blog)

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

When queryMode is set at delta or periodDelta, the API adds an ACTION field in the XML output to signify if the record is an INSERT, CHANGE, DELETE or NO CHANGE.More details about each action code is given below

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

Deletion of noneffective dated data:-

An employee enters a new national ID card (PAN for India), the below diagram shows how the data will look like in the CompoundEmployee API delta mode XML output.

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

Compound Employee API output XML shows the inserted record.

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

The below diagram shows the data after deletion of PAN number. The ACTION flag has been changed from “INSERT” to “DELETE”

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

Compound Employee API output XML shows the inserted record.

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

Please note, for the portlets email information and phone information, if one amends an existing record by changing the phone type ( or email type) – for example, personal mobile changed to business mobile ( or personal email type changed to business email) – SF deletes the old record and creates a new record for the changed phone type and email type. So after the change, in the query 2 records will appear one with action “DELETE” and one with action as “INSERT”.

Deletion of effective dated data:-

As mentioned in the beginning, there are multiple effective dated portlets for which record can be deleted. I have considered the address portlet in this example.

An employee can have different address type ( for e.g home address, permanent address, mailing address),

When a new Home address is inserted, data in SF screen appears as below.

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

Compound Employee API in delta mode return the data as below

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

Now let’s delete the home address record and see how the data appears in the API output XML

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

SAP SuccessFactors Employee Central, SAP SuccessFactors HCM Suite

There are few other scenarios where manager/HR ops can delete records ( e.g global assignment, termination record), for those scenarios as well it is possible to retrieve the deleted data using the compound employee API in delta mode