Symptom
You are trying to get data from SuccessFactors using OData API and it's not returning future or historical records in the output, only the recent time slice is being returned.
Environment
- SAP SuccessFactors HCM Suite
- OData API
Reproducing the Issue
The following query returns only a single record, the record which is currently active, and is not returning historical (past) and future dated records: https://<hostname>/odata/v2/EmpJob?$filter=userId eq 'EXAMPLE1'
Cause
OData by default sets the query as asOfDate, which returns only the records that are effective as of today. If you are looking for a record that is not active (that being because it's a historical record that is no more active, or because it's a record that has not been effectivated yet) then the filter explained below should be used.
Resolution
By using the filters below, you are able return multiple records, depending on the available information.
- fromDate
- toDate
FUTURE DATED RECORDS
- Filters: fromDate=2040-01-01 AND toDate=2040-30-01
- Example of query: https://<hostname>/odata/v2/EmpJob?$filter=userId eq 'EXAMPLE1'&fromDate=2040-01-01&toDate=2040-30-01
- Result: All records effective between the January 1st 2040 and January 30th 2040.
HISTORICAL RECORDS (PAST)
- Filters: fromDate=1900-01-01 AND toDate=1900-30-01
- Example of query: https://<hostname>/odata/v2/EmpJob?$filter=userId eq 'EXAMPLE1'&fromDate=1900-01-01&toDate=1900-30-01
- Result: All records effective between January 1st 1900 and January 30th 1900.
ALL TIMESLICE
You might also like to retrieve all informations since a date, meaning that you only want to restrict the information FROM a date, and not TO a date. On this scenario you should use only fromDate parameter. This will allow you to return historical as well as future dated records.
- Filter: fromDate=1900-01-01
- Example of query: https://<hostname>/odata/v2/EmpJob?$filter=userId eq 'EXAMPLE1'&fromDate=1900-01-01
- Result: All the records that the effective start date is after (including) January 1st 1900 all be retrieved, including future dated records.
See Also
Keywords
OData API, future dated records, API, OData, future date, historical records, past, fromDate, toDate, EC, Employee Central , KBA , LOD-SF-INT-ODATA , OData API Framework , How To