SAP Knowledge Base Article - Public

2092849 - How to create a Business Rule to validate data on change/save, and provide a Warning or Error message

Symptom

  • We need to create a message that pops up when a certain field is not filled in, or to validate certain field criteria either on change or on save. 
  • We would like to validate whether a certain field is set correctly, or just prompt the end user to check to ensure certain data is filled out correctly in the EC portlet.

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 Employee Central

Resolution

Scenario 1 - onChange)

  • In this scenario we will be raising a Warning Message when the Business Unit is changed, prompting the end user to verify that the FTE field is correctly populated -:
  1. Create the Warning Message you wish to display when the rule is triggered. This is done via Admin Center > Manage Data > Create New “MessageDefinition”

Message_Definition.JPG

  1. Create the rule via Admin Center > Configure Business Rules, set the Base Object to the EC portlet this rule will be triggered in, and then in the IF condition, set the field/value the system needs to validate. In the below example we have added a few different checks to validate whether the Business Unit value has changed in the transaction, or whether the FTE value is Null (blank) or whether the FTE value is 0 (note you can choose different fields to validate against to determine whether the rule should trigger or not) -:

RuleExampleFTE.JPG

Please note in this example we use the "Error" option to raise this message. The error option will prevent the transaction from saving if used in an onSave rule, until the IF conditions of the rule are no longer met. In the above scenario (onChange) the rule will trigger but not prevent saving the transaction

  1. You will then need to assign this rule as a trigger to your configuration, which can be done via Business Configuration UI (BCUI) (Admin Center > Manage Business Configuration) > navigate to the element which your rule has its Base Object defined. In the below example we created a Job Information rule, which we will assign to the field Business Unit in the Job Information element. We click "Details" link next to the field "Business Unit" and in the Details menu, we look to the bottom of the pop-up and assign the new rule there (as we want the rule to trigger when changing the Business Unit field) -:

BCUI_onChange_rule.JPG

  1. In this scenario the rule is setup to trigger “onChange” on the Business Unit field in Job Info, so when Business Unit is changed, OR when the FTE is Null OR FTE is 0, then the system will trigger the rule warning.

Error_Rule_is_triggering.JPG

Scenario 2 - onSave)

  • In this scenario, we have configured a rule to trigger on save, and it will check the values in the Business Unit and FTE fields as before, and if they are equal to what is defined in the rule, a Warning message will be triggered (a bit different to an Error message) -:

WarningRule.JPG

  1. You can configure this rule to trigger “onSave” based on other validation information. Again this is set in the BCUI (Admin Center > Manage Business Configuration) and again set in the related element - Job Information - but this time we will assign it to the element itself as an onSave rule (which is done at the bottom of the element view) -:

onSave.JPG

  1. “onSave” rules trigger upon clicking the save button, and the Warning message will allow the operator either Proceed and save the change, or, Correct to abort the save and make the requested adjustment -:

 WarningTriggered.JPG

  • You could also change the Message Type to either "Error" (it will not let the operator proceed until the rule passes validation) or "Info" which will pop up for 5 seconds with the message, offer no options, and continue the save operation.

Please Note: 

 - These rules are only triggered in the UI, they are not triggered on data imports. The raise message will not be triggered in any form on the import of data. 
    The rule will still be process in any rule trace, but there is no logic to display raise messages on import of data. Any change to this logic would be considered an enhancement request.
   
    In recent releases, support for Raise Messages in Imports are being added to selected HRIS Elements listed in: Centralized Services Enhancements for Employee Data Imports

 - Rules on generic Objects (MDF):
    - Raise message Business Rules on MDF objects, must be set as Validation Rules.
    - With regards to MDF Foundation Object the above will work based on MDF not as expected. With MDF both Error and Warning messages are displayed as Confirmation.
      Which is inconsistent with the behavior of EC Core Objects as they can display as both Error and Warning
    - Make sure that the rule for generic object have the MDF context and purpose as explained on following KBA: 2768151 - Triggering workflows on MDF objects using business rule.

FAQ - Additional Information

Q) Where can I get information on this from the Guide?

A) Guide: Implementing Business Rules in SAP SuccessFactors

See Also

  • 2768151 - Triggering workflows on MDF objects using business rule
  • 2080138 - How to Propagate fields using Business Rules
  • 2621890 - Troubleshooting Business Rules in Employee Central 
  • 2331851 - Employee Central - Business Rules

Keywords

EC , Success Factors , Raise Message , Error Message , Warning Message , Business Rule, import, MDF, GO, Generic Object , KBA , sf employee , sf employee_central , raise message , LOD-SF-EC-BCI , Manage Business Configuration (BCUI) & Data Models (XML) , LOD-SF-EC-FOO , Foundation Objects (Organisation, Pay and Job Structures) , How To

Product

SAP SuccessFactors Employee Central all versions ; SAP SuccessFactors HCM Suite all versions

Attachments

a.jpg
image b.jpg
image c.jpg
image d.jpg
image e.jpg