odatadatabase-replicationsap-successfactors

Query deleted records via SF OData API?


I am replicating the Successfactors Employee Central Data (including FO, MDF, BG elements and etc.) via OData API to local database for third party integration.

It is able to trace changed records by filtering last modify date. However, the deleted record is not able to capture from OData API. Hence I cannot delete the record in my local database when corresponding EC record is deleted.

Is there any way I can get the deleted records from the API or other sources? Thanks.


Solution

  • OData API is not able to handle this task.

    Extract from SF OData API doc:

    Don't use our OData APIs when:

    ● Your system cannot consume either OData APIs or SOAP for an initial data load. In this case, you would go for Import/Export with a CSV. Automation via FTP would also be a possibility.

    You need employee replication field level delta, snapshot, or read modified employees only, then SOAP Compound Employee API is your tool of choice. You can find more information in the guide Implementing the Employee Central Compound Employee API.

    ● You only need to read data, then the SOAP Compound Employee API would also be your tool of choice.

    However with SFAPI (SuccessFactors CompoundEmployee API) it's easy. SFAPI has a special parameter changedSegmentsOnly that does exactly just what you want, the API returns only changed segments with an action code not equal to NO_CHANGE in delta transmission.

    You make a query, for example, for changed employee data:

    <urn:query>
     <urn:queryString>select person,
                             personal_information,
                             address_information,
                             email_information,
                             phone_information,
                             employment_information,
                             job_information,
                             compensation_information,
                             paycompensation_recurring,
                             paycompensation_non_recurring,
                             direct_deposit,
                             national_id_card,
                             payment_information
                             from CompoundEmployee
                             where person_id_external = 'cgrant'
     </urn:queryString>
     <urn:param>
         <urn:name>resultOptions</urn:name>
         <urn:value>changedSegmentsOnly</urn:value>
    </urn:param>
     <urn:param>
         <urn:name>maxRows</urn:name>
         <urn:value>50</urn:value>
     </urn:param>
    </urn:query>
    

    This API query will return you all the employees that were changed or deleted.

    enter image description here

    After that you can filter your response by that field.

    ADDENDUM: any change to MDF entity, both standard and custom, can be tracked via OData Audit logs. How to enable them:

    1. Go to this setting in API center

    enter image description here

    1. Enable this switch. It can be enabled for SFAPI as well

    enter image description here

    1. This way all API calls payloads will be saved and you will be able to see what entity was changed with each call

    enter image description here

    Prerequisite: the object must be visible by API and MDF version history must be enabled

    More about API types for SuccessFactors: