In this example, you wish to format a phone number, so that numbers beginning with 0, are formatted to begin with (0).
Employee Central 2.0 - Phone Info
Reproducing the Issue
Navigate to the Personal Information page of a user.
When entering a phone number in the Contact Information portlet that begins with 0, it should be formatted to begin with (0).
You need to create a business rule to do this.
- Navigate to ‘Configure Business Rules’ in Admin Centre.
- Create a new business rule with Base Object ‘Phone Information’:
- Populate the business rule as follows:
- The ‘IF’ condition, uses the ‘Matches()’ function to check if the phone number entered, matches the defined format. The format is defined as any number that begins with 0.
(.* = The asterisk indicates zero or more occurrences of the preceding element.)
- The Then condition firsts uses the ‘Format()’ function to format the number using the template. The template is defined as (0)%s. This is a string starting with (0).
(%s = a string.)
- The Then condition then makes use of the ‘Substring()’ function, to define the end of the string (%s) from the template. We set the ‘Phone Number’ as the string that we are taking the substring from. We then start the substring at index 2. The length is optional and should be left ‘Null’ as there may be different length phone numbers.
(The index of a sting is the position of a character in the string. Strings start at index 1.)
- Saved rule:
- Trigger it as ‘onChange’ on the ‘phone-number’ field in the ‘phoneInfo’ element.
- Navigate to the Personal Information page of a user. When entering a phone number in the Contact Information portlet that begins with 0, it is formatted to begin with (0).
Enter a number begining with 0:
The number is formatted to begin with (0):
Format Business Rule Phone Number phoneInfo , KBA , LOD-SF-EC-RUL , Business Rules & Event Derivation , LOD-SF-EC , Employee Central , How To