SAP Knowledge Base Article - Public

2914208 - How to use Business Rules to Validate Field Value Format with Special Characters and Length - RCM

Symptom

  • This article describes how to use Business Rules in Recruiting to validate if a field value has been entered in the correct format, like US Phone Number number format "+1 (111) 222-333". You can use these instructions to apply the rule in any other number/alphabetical format, like these examples: "ABC-123", "A2C.1B3", "Abc-123/a10".
  • This article also describes how to validate a field value length.
  • Besides checking the value, you can remove the value entered and ask the user or the candidate to fill the field again, until the correct format is entered. These instructions are also described in the article.
  • The same rule structure can be applied to Job Requisition, Candidate Profile, Job Application and Offer Letter.
  • This rule will only be executed on the UI.
  • Notice that the article intends to show the Business Rule feature capability and let the users be more familiar with the tool. The rule described can have different behaviors on different systems. Please reach out to your Implementation Team and/or Partner for implement the same if you are having any issues with it.

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 Recruiting Management - All Versions

  • Business Rules in Recruiting

Resolution

Rules to validate the field value format:

  • Candidate Profile and Job Application rules are not supported when Mobile Apply is enabled. Business Rules for Mobile Apply are on road map and will be enhanced on further releases (2866437 & 2781775).
  • It's possible to define this rule structure to all 4 Recruiting templates. Please, make sure to select the correct template while creating the rule.
  • If you are using this rule to apply format in the standard SSN field, notice that the SSN field is classified as PII (personally identifiable information) and cannot be used in Business Rules - 2869141.
  • When selecting a template, you will only be able to work within the selected scenario. For example, if you create a Candidate Profile rule and you want to have the same on the Job Application, you must create a Job Application rule as well.
  • A validation will make more sense to the user or the candidate if the rule brings a message or a warning after the execution. Please refer to the end of the article on how to create a message in Manage Data. OnSave trigger event does not support raise message function.

Each validation will require a specific regular expression. Please refer to the below expression:

Only digits from 0-9:   ^[0-9]+$

Only alphabet letters:   ^[a-zA-Z]+$

Only upper/lowercase alphabet letters:   ^[A-Z]+$  OR  ^[a-z]+$

Only alphanumeric:  ^[a-zA-Z0-9]+$

If you want to include space ( ) in the above validations, you need to include a space, a non-breaking space, after the last value, as the following example (Notice the space after the number 9):

Without Space:   ^[a-zA-Z0-9]+$

With Space:        ^[a-zA-Z0-9 ]+$

To validate any format above with a specific length, you will be using the following expression. You can change the length limit to any number.

Only digits with a length of 1-20:   \d{1,20}

Only alphabet letters with a length of 20:   [a-zA-Z]\{20\}

Only alphanumeric with a length of 20:   [a-zA-Z0-9]\{20\}

To add any special character and create a format, you need to follow the next example.

For this example, the US Phone format will be used "+1 (111) 222-333": 

[+]\d{1,2}[ ][(]\d\{3\}[)][ ]\d\{3\}[-]\d\{3\}

You can build any format you want, like the following examples:

[a-zA-Z]\{3\}[-]\d\{3\} = "Abc-123"

\d\{2\}[.][a-z]\{2\}[/][A-Z]\{2\} = "12.ab/CD"

[a-zA-Z0-9]\{5\}[-][a-zA-Z0-9]\{3\} = "a1BC2-de3"


Sample Case: Validating a field to receive only US Phone Format.

Base Object: Job Application

Trigger Event: OnChange

Steps to create the rule:

  1. Go to Configure Business Rules and click Create New Rule.
  2. Select Recruiting option and choose Job Application: Basic Business Rule Scenario.
  3. Type the Rule Name and Rule ID.
  4. You can leave the Start Date as it is.
  5. Description if desired.
  6. Click Continue
  7. On "IF" parameter, set the field in which you to do the validation. Then select "Is not equal to" and "Null". This is required to ensure that the rule will not be triggered in case the field is empty.

  8. Now you need to add another condition. For that, open the dropdown, open Add and select the Parent Add option.

  9. After adding a new condition, click o the "+".
  10. On the first dropdown, select Matches() option. On the right side of the box, select "Is Equal To" > "Boolean" > "No".
  11. String to be Checked: The field where the validation will occur. Same as the first condition.
  12. Regular Expression: [+]\d{1,2}[ ][(]\d\{3\}[)][ ]\d\{3\}[-]\d\{3\}
  13. The above expression will be for entering only numbers in the US Phone Number format. You can use any expression provided listed above.
  14. On "THEN" parameter, set the first option to "Raise Message".
  15. On "Message" select the message you want to throw it. For more information on how to create a message, please refer to the article 2610536 - RCM Business Rules: Raise Message
  16. You can choose any severity type.


    The next steps will instruct you to use the rule to also clear the information from the field if the value entered is invalid. This will force the candidate/user to enter the correct value. It's important to make it clear on the message which are the correct values. In case you don't want to have this scenario, you can move to step 19.

  17. Click on "Add Expression" on the right side of the rule.
  18. Then on the first option, select "Set" the field where the validation will occur (Same as above steps), select "To be Equal to" and "Null". This will make the rule to turn the field value into "Null" after the message is raised, therefore every time a wrong value is entered, the field will be automatically cleared. 
  19. Save the rule. You will be able to modify it anytime.
  20. Go to Manage Rules in Recruiting.
  21. On Candidate section, on Field Change Rules (onChange event type), select the field and the rule.
  22. Save the changes.

See Also

2610536 - RCM Business Rules: Raise Message

2866437 - Business Rules on Job Application are not triggering - Recruiting Management

2781775 - Business rules are not getting triggered for Candidate Profile - Recruiting Management

2618607 - Manage Rules in Recruiting Management

2704222 - Business Rules Are Not Being Saved - Recruiting Management

2869141 - Candidate Application SSN field not found when creating rule

2913572 - How to use Business Rules to Convert a String Value To Upper/Lowercase - Recruiting Management

2913809 - How to use Business Rules to Validate Field Value Format and Length - RCM

2919193 - How to use Business Rules to Validade Candidate Age - Recruiting Management

2921494 - How to Use Business Rules to Disqualify a Candidate Based on Field Values (Pre-Screening) - RCM

Keywords

Business Rules, Rule, Recruitingn RCM, Validation, Regular Expression, Phone Format, SSN, National Identification, Length, Special Characters, Format , KBA , LOD-SF-RCM-RUL , Recruiting Rule Issues with MDF Platform , How To

Product

SAP SuccessFactors Recruiting all versions

Attachments

Pasted image.png
Pasted image.png
Pasted image.png