Symptom
- How can I trigger a workflow using Business rule?
- How to create a Business rule to initiate a workflow on custom MDF objects?
- What are the different ways to trigger workflows on MDF objects?
- Deletion of the data in MDF objects does not trigger the workflow process.
Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental
Environment
- SAP SuccessFactors HCM Suite
- Metadata Framework (MDF)
Reproducing the Issue
Background: Workflow can be set using two ways:
A) Using "Workflow Routing" property on the object level. Add the workflow name in the "Workflow Routing" field;
B) Dynamically, through scenario based business rule.
You will choose the "Rules for MDF Based Objects" scenario and "Workflow" as purpose.
Resolution
To trigger a Workflow via Business Rule, follow the steps below:
1. When creating a new MDF Rule Scenario, select Workflow as a purpose:
2. Then further choose like below:
3. This rule has to be further configured on the "Save Rules" section of the object.
NOTE:
1) It is recommended to refer to Workflows in MDF | SAP Help Portal for fixing below common issues in MDF Workflow by running items from Check Tool:
-
Remove all non-actionable MDF records from Manage Data if there are no workflow requests associated with them. (AssociatedWorkflowForNonActionableRecord)
-
Remove all non-actionable MDF records from Manage Data if the status of the associated workflow requests is not yet approved or rejected, and set their workflow status to cancelled. (ValidWorkflowStatusForNonActionableRecord)
-
Regenerate to-do tasks for approvers on the home page for non-actionable records with a valid workflow. (TodoTaskForNonActionableRecord)
-
Remove MDF records with in-progress workflow status as these records can be edited from the Manage Data page, making them actionable. (InProgressWorkflowWithApprovedRecord)
2) In case Pending data has been set to Yes => The save rules on the object level trigger twice. First when the initiator creates the data and secondly when the last approver of the workflow process finally approves the data.
If you have a requirement as per which you do not want the rule to trigger twice or want to limit the rule execution at only one event ==> You need to do that by providing "if-else" conditions in the rule.
Example: If you want the rule to be triggered only by approver at the end and not when the initiator creates the data - You should put condition like below in the rule:
If LoginUser() = UserID
then perform calculations
Else
do nothing.
3) If you're setting the workflow via "Workflow Routing" => It automatically triggers at the Save event and also on the Delete event (when you save and delete the data in MDF object respectively).
But if you're setting the workflow via business rule then it will trigger only on the save event. If you want the workflow process to be triggered also on the delete event => Then you have to configure the same workflow rule on the "Delete Rules" section of the object as well.
4) Similar with OnInsert rules -> if a workflow is sent for approval with an OnInsert rule - the data waiting to be approved is at this point set as "pending data = yes" which not fully committed to the database. The data is only committed to the database after the approval of the workflow. Should the data be updated/edited before the final approval of the workflow, this will trigger the OnInsert rule again as it is considered a new insert not a change.
5) Workflow business rules are not available for Child objects (the option to select workflow is not available when creating the business rule based on the child). So use the rule in the parent, observing the limitations listed in KBA 2839730 - MDF Parent object triggering the wrong workflow based on the child record inserted - SAP for Me.
See Also
Keywords
MDF, Metadata Framework, MDF Workflow, MDF Business Rule, wfConfig, Scenario Based rule, Basic Rule, custom MDF, workflow routing, child record, composite child , KBA , LOD-SF-MDF-WFL , Custom Object based Workflows , LOD-SF-MDF-RUL , Custom Oject based Business Rules , How To
SAP Knowledge Base Article - Public