cancel
Showing results for 
Search instead for 
Did you mean: 

Successfactors: Odata API to create a time off entry for an employee

Former Member

Hi,

We have a web application which needs to create a time off vacation entry for users in Successfactors. Obviously, we need to use SuccessFactors Odata APIs to do this. We are looking for the specific APIs that we can use to do the following:

1. Query by giving an employee number and get their time off balances

2. Create a time off request for a specific start date and end date and time off type.

Regards

Ravi

0 Kudos

hai ravi,I am also facing same issue,please help me out

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member206574
Active Participant

Hi Ravi,

Check the below entities for your queries.

1. Query by giving an employee number and get their time off balances

https://<hostname>/odata/v2/EmpTimeAccountBalance?$filter=userId eq '<userIdValue>' and timeAccountType eq '<timeTypevalue>'

above service will give you the total leaves for the current year in the property balance.

https://<hostname>/odata/v2/EmployeeTime?$filter=userId eq '<userIdValue>' and (timeType eq '<timeTypevalue>') and (startDate ge datetime'2017-01-01T00:00:00')

in response u can find the property deductionQuantity for the timeType. this is a list of records for the current year. sum all the deduction quantity from the response list.


balances = balance - (sum of deductionQuantity)

2. Create a time off request for a specific start date and end date and time off type.

https://<hostname>/odata/v2/EmployeeTime

Payload:

{ "__metadata" : { "uri" : "http://<hostname>/odata/v2/EmployeeTime", "type": "SFOData.EmployeeTime"}, "startDate": "/Date(1483920000000)/", "endDate": "/Date(1483920000000)/", "externalCode": "<some unique value>", "userIdNav": { "__metadata": { "uri": "https://<hostname>/odata/v2/User('<userId>')", "type": "SFOData.User" }}, "timeTypeNav": { "__metadata": { "uri": "https://<hostname>/odata/v2/TimeType('<timeType>')", "type": "SFOData.TimeType" } } }

Consider the property externalCode which should be unique value always like key parameter while creating.

Regards,

Venu

0 Kudos

HI Ravi,

Have you tried the solution provided by Venu? Did it work? Thanks

KP-1
Discoverer
0 Kudos

Hi Venugopal,

I did try this and I am surprised by the results.

This query delivers the results that is expected, however, I am afraid I have to say, the Workflow doesnt get triggered at all.

Do you have anything specific in mind to make it work?

Thanks,

Kunjal

0 Kudos

THANKS¡ Venugopal

former_member603293
Discoverer
0 Kudos

Hi Venugopal,

I have same question with Kunjal.

How to trigger the workflow(approve the leave request etc.) by using this API?

Thanks. Kevin

former_member512458
Discoverer
0 Kudos

Hi Kunjal & Kevin,

In order to trigger workflow

please use following endpoint

POST https://<HOSTNAME>/odata/v2/upsert?workflowConfirmed=true&$format=json

{

"__metadata": { "uri": "https://<hostname>/odata/v2/EmployeeTime", "type": "SFOData.EmployeeTime" },

"startDate": "/Date(1484677800000)/",

"endDate": "/Date(1484739000000)/",

"externalCode":"<UNIQUE VALUE>",

"approvalStatus": "PENDING",

"userIdNav": { "__metadata": { "uri": "https://<hostname>/odata/v2/User('<USERID>')", "type": "SFOData.User" } },

"timeTypeNav": { "__metadata": { "uri": "https://<hostname>/odata/v2/TimeType('<TIMETYPE>')", "type": "SFOData.TimeType" } }

}


This will trigger workflow.

Try to use oAuth for this POST. If you use a technical user than make sure, it has no admin access to MDF oData API as below statement

The parameter has no impact on admin users with the Admin access to MDF OData API permission. If an admin user creates or changes a record for a workflow-enabled entity, no workflow is triggered and the record is saved as normal data.

https://help.sap.com/viewer/d599f15995d348a1b45ba5603e2aba9b/1911/en-US/886cdf72d3474996889d0b306d30...

Kind Regards,

Ravi

Kshetrali
Explorer
0 Kudos

hello Ravi,

unable to open the link mentioned by you.

https://help.sap.com/viewer/d599f15995d348a1b45ba5603e2aba9b/1911/en-US/886cdf72d3474996889d0b306d30...

Kindly help with description or correct link.

Radoslav
Explorer
0 Kudos

This really helped me. The API documentation is terrifying 😄

former_member48810
Discoverer
0 Kudos

how to query in bulk data abstraction for number of leaves

lenastodal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Pankaj - Quick tip that might help you get an answer to your question quicker:
Please raise your question again as a new question and follow our rules of engagement: https://community.sap.com/resources/rules-of-engagement. The author of the original question is no longer active in the community and won't receive your query. With the help of our Q&A tutorial: https://developers.sap.com/tutorials/community-qa.html, you'll be able to prepare questions that draw responses from our members.
Thank you!

0 Kudos

Documentation provided by SAP-

https://help.sap.com/doc/7efdca36492e47c7b20ab92c4ca6323c/1908/en-US/SF_EC_OData_API_REF.pdf

API 1-https://<host>/odata/v2/EmpTimeAccountBalance?$filter=userId eq '3334343' and timeAccountType+in+'EL_Ind','SL_Ind','CL_Ind' &$format=json

Above API will give you the total available leaves as of today date.

API 2: https://<host>/odata/v2/EmployeeTime?$filter=(userId eq '3334343') and (approvalStatus eq 'APPROVED') and (timeType eq 'CL_Ind') and (startDate gt datetime'2019-10-19T00:00:00') &$format=json

Above API will give us list of approved leaves of an employee by passing user id and status Approved and Time Type And date greater than today date.

Get Total available leave balance for particular leave type:

Total Leave Balance=API 1(balance)- API 2 (sum of deductionQuantity)


Thanks

Priti

siddharthrajora
Product and Topic Expert
Product and Topic Expert
0 Kudos

also you can get using Integration center also, ie simple querying the data

souptiksom
Explorer
0 Kudos

Unable to do that. Please share the steps.