Triggering workflows for MDF using OData API
This blog explains how you can trigger workflows attached to a MDF object using OData APIs.
I will demonstrate this with a simple custom MDF. The custom MDF has three fields externalCode as AutoNumber, User ID as USER and comments as String.
The workflow Manager_approval is attached to the above MDF. This Workflow has only one step which is basically routed to employee’s (User’s) manager.
In this example, I am making use of REST tool called POST MAN to make things simple. You can call Odata API’s from any web application.
1. Enter the Odata API URL based on your Data Center. Since my demo is in sales demo 4 the following is the URL: https://apisalesdemo4.successfactors.com/odata/v2/
2. For this example, we can make use of Basic Authentication. Enter the technical user from your demo instance in the following format as shown:
Make sure the technical user that you use does not have admin access to Odata API as shown below. Only a non admin user can trigger a workflow on OData call.
3. Construct the URL and message body for OData Upsert. For this example, we can make use of Basic Authentication. Enter the technical user from your demo instance in the following format as shown:
Note: we need to pass a flag named ‘workflowConfirmed=true’ in the request URL. When workflow is triggered from UI, we see a popup asking for confirmation.This flag denotes this behavior when creating data from APIs.
The User Alex Anderson which we are using has the user ID as ‘aaaa’ and manager as Joseph tong:
4. Trigger the OData API call and check the response. If the response has the code ‘200’ then your OData API call is successful:
5. Verify that the workflow is triggered for above OData upsert call. Login as manager Joseph Tong and we see the workflow as shown below: