InThis blog, am going to explain how we can configure validations and formats for different telephone numbers for each country using custom MDF and rules with respect to the international standard.
SuccessFactors Employee Central allows us to maintain different types of telephone numbers in Phone information portlet, but we do not have any in-built standard validation with respect to international standards while maintaining telephone numbers.
Country-specific validations for Telephone numbers have been a requirement for many customers to align with International standards on maintaining different types of phone numbers. Portlets like National ID have standard validations with respect to the country, but we do not have similar kind of validations as a standard feature for telephone numbers.
Identifier “phone-number” in phone info portlet is configured to data type “String” as standard, which means it will accept numbers as well as alphabets.
We are taking country HongKong as an example, which has 3 different Phone Types with a telephone number for each phone type varies accordingly.
|Phone Type||Country Code||Area Code||Phone No Validation||Validation|
|Business||To be defaulted based on Job country(Can be editable)||To be defaulted based on Job country(Can be editable)||Should accept only 8 digits||Error message if more than 8 digits or alphabets entered|
|Cell phone||To be defaulted based on Job country(Can be editable)||To be defaulted based on Job country(Can be editable)||Should accept only 10 digits||Error message if more than 10 digits or alphabets entered|
|Other||To be defaulted based on Job country(Can be editable)||To be defaulted based on Job country(Can be editable)||Should accept only 12 digits||Error message if more than 12 digits or alphabets entered|
Let us create a Custom MDF, I named it as “Phone Number Validator” and configured below fields,
Pic 1: Screenshot from object definition tool.
Country mapped to external name and Phone type field configured as picklist with respective values matching actual phone information portlet.
Very importantly, we should have a field(String) for regular expression’s where we maintain the regular expressions to validate phone number and formats.
Pic 2: Screenshot from Manage Data
If we notice, field “Regular Expression (Phone Number)” and Field “Regular Expression (Area Code)” are not editable, I made this field not editable purposefully so that in future if there are any changes to the validation digit, the customer should not struggle in entering regular expressions.
To make customer friendly, I made an On change rule and mapped it to Phone Number Digit Validator field and Area Code Validator field.
Below rule will populate regular expression once the validation digit is entered.
Pic 3: Screenshot of the rule to populate regular expression.
Below screenshot to show how regular expression looks when it gets populated with the help of the above rule.
Pic 4: Regular expression populated.
Now maintain the country, country code, phone type, area code and Phone number validation digit respectively for each of the phone types.
Sample Screenshot for country Hong Kong and Phone Type Business with validation digit set to 8Pic 5: Screenshot of maintained data
Sample Screenshot for country Hong Kong and Phone Type Cell Phone with validation digit set to 10Pic 6: Screenshot of maintained data
Sample Screenshot for country Hong Kong and Phone Type Other with validation digit set to 12Pic 7: Screenshot of maintained data
This will be a one-time activity, you can also do mass upload, similarly create for each country with respect to phone types.
Pic 8: Screenshot of maintained data
Now, we have to create and configure the actual rule which will validate phone number format and digit with respect to custom MDF “Phone Number Validator”
Pic 9: Screenshot of maintained rule
Map the above rule in phone info and have a custom message to show up as an error, apart from this rule please have another rule to default country code with respect to user job country(Optional).
Sample Screenshots: Tested.
Country Hong Kong, with phone type Business, should accept only 8 digits else it should error out.
Country Hong Kong, with phone type Cell Phone, should accept only 10 digits else it should error out.
Country Hong Kong, with phone type Other, should accept only 12 digits else it should error out.
All the above screenshots are for reference purpose only, please explore more and be creative in field labels and custom messages.
By this method, we can avoid creating a 100 line rule for each and every country, hope this helps.