Symptom
- When using interfaces to transfer information from SuccessFactors for Payroll purposes, you encounter errors when special characters are entered in fields such as Address Information and Personal Information fields.
- How can you create a Business Rule set to raise an Error Message when Special Characters such as ',''£' '$' '#' '%' etc. are entered in a field?
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 Cloud
Reproducing the Issue
For the purpose of this KBA, we will use the example of a comma (,) as a Special Character in fields for 'Address Information'
- Navigate to Admin Centre > Action Search > Search for a user
- Scroll to the Address Information Portlet > Add an address for this user with commas included
- Click 'Save' > System saves this Address without any validation performed for the fields with commas maintained
Cause
You need to create a rule which can check if Special Characters are being entered into the field, and if so, raise an error message notifying the user to not use Special Characters in these fields
Resolution
Using the 'matches()' function and Regular Expression you can create a business rule to check for Special Characters and raise an error message based on this;
First, you will need to create the Error Message, to do so;
- Navigate to Admin Centre > Manage Data > Create New > 'Message Definition'
- In the 'Text' Field, enter the text you wish to display when the error message pops up, for example 'You cannot use Special Characters in Address Fields'
- Give the Message Definition a 'Name' and 'External Code' > Status = 'Active' > Save
Next, create the Business Rule and attach the Error Message, to do so; - Navigate to Admin Centre > Configure Business Rules > Create New Rule > Select 'Basic' Rule
- Give the Rule a sensible name such as 'Special_Character_Check' > Select 'Base Object' 'Addresses Model' (Change the Base Object as necessary depending on the fields you want to check, e.g for Personal Information Fields, select Base Object 'Personal Information Model')
- In the 'IF' statement of the rule, select the 'Matches()' function > 'is equal to' 'Boolean' 'Yes'
- In the 'String to be checked' box, scroll to the field you wish to have checked for Special Characters > Click + > Select 'Value'
- In the 'Regular Expression' box, Select 'Text' > Add the following Regular Expression in the Text Box;
.*[!@#$%^&*()_+={}"?;:<>\\\[\]\-\'].* - Note: To add more characters to be checked in the Regular Expression, you can add them between the '[]' brackets. To remove characters to be checked, simply delete them from between the '[]' brackets.
- Note: You must include the .* in front of the [ ] and behind the brackets, else the rule will not work as expected.
- .* [...].*
- Note: Some special characters like [ ] \ ' - are considered special characters in a Java regex expression. Therefore these characters will not be working in the validation rule unless you add a backslash before these characters.
- examples: if you want to consider [ as special character in validation rule, you need to put .*[\[].* and not just .*[[].*
- To add more fields to be checked in the rule, select the dropdown next to the eye > Add > Parent Or > Click '+' (Keep clicking '+' to add additional fields) > Repeat Steps 6-8 until all the required fields you wish to check are in the rule
- In the 'THEN' statement of the rule, select 'Output Type' 'Raise Message' > In 'Message' enter the Name of the Message Definition created > Set Severity to 'Error' > Click 'Save'
- Add the rule to the Address Information Portlet by Navigating to Manage Business Configuration > select HRIS Element 'homeAddress' > Scroll to 'Trigger Rules' > Select 'Home Address Model' as the Base Object > Set the rule 'onSave' > Enter the Name of the rule under 'Rules' > Click 'Save'
After doing so, you will receive the error message when trying to add a special character into the selected fields
See Also
2426526 - How to use a Business Rule to apply a Format/Regular Expression to a Field
Keywords
Special Characters, Special, Characters, Character, Address Information, Personal Information, Validate, Validation, Regular Expression, Business Rule, ,, !, ", £, $, %, ^, &, *, (, ), _, -, +, =, [, {, ], }, :, ;, @, ', #, ~, <, >, ., ?, /, ¬, Field , KBA , LOD-SF-EC-PER-PRS , Personal Info - Config, Rules, RBP, UI , LOD-SF-EC-PER-ADR , Home Adress - Config, Rules, RBP, UI , Problem