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
Note:
Starting H2 2023 release (aka b2311 release), when you select the Basic rule scenario to create a rule using the Basic Rule Scenario, you receive the warning that the Basic rule scenario will be deprecated and that you should choose an application-specific scenario instead. You should only continue with the Basic scenario in cases where none of the application-specific scenarios meet your needs.
In few cases of complex Rules which needed Edit and addition of wfconfig, this created a problem. So to prevent this we need to adopt the API developed by Rules Engine Team in b1905 to:
- -Show wfconfig in Basic Rules
- -Hide wfconfig in new MDF Rule Scenario based rules.
Post 1905 behavior should be as below:
- When creating or Editing Basic Rules for MDF Object, user should be able to see the wfConfig property.
- User should be able to set the wfConfig in Basic Rule and the Rule should be executed successfully.
- When creating a new MDF Rule Scenario, the user should not be able to see wfconfig when creating/editing for any purpose except for Workflow.(Must select ‘Workflow’ as Purpose).
- Then further choose like below:
5) This rule has to be further configured on the "Save Rules" section of the object.
NOTE:
1) 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.
2) 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.
NOTE:
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.
See Also
Keywords
MDF, Metadata Framework, MDF Workflow, MDF Business Rule, wfConfig, Scenario Based rule, Basic Rule, custom MDF, workflow routing, wfconfiguration , KBA , LOD-SF-MDF-WFL , Custom Object based Workflows , LOD-SF-MDF-RUL , Custom Oject based Business Rules , How To