on 05-12-2017 3:12 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Kind Regards,
Ravi
hello Ravi,
unable to open the link mentioned by you.
Kindly help with description or correct link.
how to query in bulk data abstraction for number of leaves
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
also you can get using Integration center also, ie simple querying the data
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.