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:
Hi Neelesh,
I've implemented this solution on postman and it works fine. However, I am unable to implement this same solution on HCI. I've created an iFlow that sends data to an MDF trough the standard Successfactors connector for HCI. I've tried on many different ways to add this URL parameter "workflowConfirmed=true" into the connector's options without success. Have you ever tried to reproduce this solution on HCI? Do you have any idea on how to add this URL parameter into the SFSF connector for HCI?
Thanks in advance.
I am not sure of this. Can you please reach out to HCI team/or create a ticket for supporting this parameter in iflows
Thanks
Neelesh
Hi Neelesh,
Just a quick update, SAP has implemented the feature of triggering workflows for MDF by using the SFSF adapter for HCI. There is a new Custom Query Field in the newer version of SuccessFactors adapter to handle that requirement. Kindly refer SAP documentation link for details. https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/6a51910140da45c38eecf4ac2c41c99e.html
To see the new change, you will need to remove and then remodel the Successfactors adapter step once again in the latest Eclipse Tooling or Web UI.
Please find below the test evidence:
2) Result on Successfactors > Manage Workflow Requests
Best regards,
Rodrigo D. Barbaceli
This is great 🙂 Thanks for sharing. I guess this makes the Blog fully complete as well 🙂
You're welcome, I am glad to help.
Cheers!
Hi Neelesh,
Amazing post, it served me a lot and I was able to do it through HCI for several employees. The problem I have is for Composite MDFs, since I enter the records, but start the WF, is it possible to apply these steps to work these types of MDF?
Thanks,
Jorge.
Hi Jorge
Thanks for your feedback. Workflows can currently be only attached to parent MDF. Workflows at composite are not supported
Thanks
Neelesh
Hi Neelesh, Does it work for the employee central time sheet? Thanks,
Hi Daniel
As long it is a MDF and upsertable, the workflow should work
Regards
Neelesh
Thanks for the blog. I have a question ... Can the API call done through Import i.e. import a file and each record trigger a workflow
Hello,
I tried to create a request for vacations in EmployeeTimee and trigger the workflow since OData API, I can create the record in EmployeeTime but the workflow I can't do it, this functionality
it's working correctly since SuccessFactors in Employee Profile
I follow this blog and it doesn't work, Is possible to trigger a workflow to EmployeeTime since The API?
Yes it should work for Employee TIme as well. I have personally helped many customers to achieve this.
Please check if the conditions are satisfied: There should be admin workflow configured at time type and an onSave rule in employee time to trigger admin workflow . Refer KBA (https://launchpad.support.sap.com/#/notes/2548343)
Also the login or API user should not have access to admin odata MDF API as specified in the blog.
If the above is configured correctly, it should work as expected
Hi @Neelesh,
I've same situation for leave request submission with API. I've follow the KBA and make sure no access admin odata MDF API for API user but it's still no workflow generated. I've also tried to set Approval Status as PENDING and workflowInitiatedByAdmin as true but the result is same, PENDING and without workflow. Please inform if there's any entity should be set in Employee Time API or please give the sample.
Thanks
Hi Yosef Agung Wicaksono - It has worked for others. You can refer to the first two comments. They have also put the screenshots. Yes the entity is Employee Time. Please go to "Check user permission" in admin center and check that the api user does not have permission for "Admin Access to OData API". Sometimes even if there are overlapping roles. For ex Role A does not provide, but role B provides, then also it will not work. Please check for overlapping conditions
Hi Neelesh,
Yeah, it works now for Time Type with workflow. These are steps :
Thanks for your help and insight.
Great Thank you
Hello Neelesh Kamath ,
This is a very useful article!!
Is it possible call API through Import? For example import a file and each record to trigger a workflow.
Thank you in advance,
Lampros Kardaras
Thanks a lot,Neelesh
Hi Neelesh,
I am trying to update data through the Integration center on a custom MDF object. However, I am not sure how can I use workflowConfirmed=true in the integration center.
Best Regards,
Dheeraj
Hi Dheeraj,
I do not think IC supports this flag yet. You can raise a ticket to IC team to check if they support/will plan to support this flag.
However, partners have done this via CPI where this is supported. Please check some of the comments above where one of the partner has implemented this using CPI
Best Regards
Neelesh