SAP Knowledge Base Article - Public

2768151 - Triggering workflows on MDF objects using business rule

Symptom

  • How can I trigger workflow using a Business rule?
  • How to create a Business rule to initiate a workflow on a custom MDF object.
  • What are different ways trigger a workflow on an MDF objects? 
  • Deletion of the data in MDF object 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 HXM Suite
  • Metadata Framework (MDF)

Reproducing the Issue

Background: Workflow can be set using two ways:

A) Using "Workflow Routing" property on the object level.

B) Dynamically through scenario based business rule, where customer will set 'wfConfig' property of an Object Definition.

Prior to b1902 release, wfconfig was shown in Basic Rules.

Starting b1902 release, we implemented New Rules scenarios where the wfConfig property was not shown in Basic or New MDF Scenarios when creating a rule.

Cause

Because of the above change, the customers were not able to Edit the Basic Rule or add a New wfConfig to the existing Rule and workaround for this was to create a New Rule Scenario with Workflow 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:

  1. -Show wfconfig in Basic Rules
  2. -Hide wfconfig in new MDF Rule Scenario based rules.

Post 1905 behavior should be as below:

  1. When creating or Editing Basic Rules for MDF Object, user should be able to see the wfConfig property.

basic.png

  1. User should be able to set the wfConfig in Basic Rule and the Rule should be executed successfully.
  2. 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).

3.jpg

  1. Then further choose like below:

4.jpg

    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

Product

SAP SuccessFactors HCM Suite all versions