How do I use pattern matching in an autocomplete rule?

Hello, my name is Steve. In this video, I’ll demonstrate how to use a regular expression for pattern matching in an autocomplete rule. I’ll do this by creating a rule that validates that the person name fields do not have special characters. If a name field contains a special character, the rule will throw an error message.

Sign in using the username and password assigned to you and enter your sandbox. As you can see, I am already in a sandbox logged in as hcm_impl20. The yellow toolbar at the top of the page indicates that I’m in a sandbox. To navigate to the Autocomplete Rules Editor, click the Tools menu on the yellow tool bar and select HCM Experience Design Studio. On the HCM Experience Design Studio page, make sure that the Autocomplete Rules tab is selected.

From the Home page, click the Navigator icon.

Expand the Configuration section.

Click Sandboxes.

Enter your sandbox you set up to use for autocomplete rule changes.

Click Tools menu.

Select HCM Experience Design Studio.

Click the Autocomplete Rules tab.

Because we’re validating person name fields, we’ll select the Person Name business object for our rule. For the rule type, we’ll select Object Validation Rule Type.

In the Business Object drop-down list, select Person Name.

Click Add.

Select Object Validation Rule Type.

Next we enter a name for the rule. Then we want to confirm that the rule is Active so that we can test it when we’re done.

In the Name field, enter No Special Characters in Person Name.

Select the Active check box.

When we create a rule, the editor includes a default string variable. This is the variable type we need for pattern matching. We’ll add to the default variable name, so that it is a bit more descriptive. Then in the literal text field, we’ll include a regular expression, which is a special type of string that is used to match text. In this case, our regular expression will be used to check another string for any of the special characters. If a special character is found, then the pattern matching returns a value of true.

In The variable value = row, change the name to stringVar_Pattern.

In the xyz value field, enter .*[!@$%\^&*()_+=|\<>?/]+.*.

Next we want to create a condition block. In this block we’ll put the condition statements for the pattern matching.

In the Rule Logic section, click the down arrow next to the variable.

Select Add next.

Select Condition block.

The rule editor automatically creates an Else block as part of the condition. But we won’t need it for our rule so we’ll delete it.

Click the down arrow next to the If.

Select Delete else block.

The editor automatically give us a condition with a field from the business object. But it’s not a field we need, so we’re going to change it. We’ll change it to the person’s first name. We also want to change the string comparison operator Equal to. For pattern matching, we want this to be Matches.

Click Person Name Character Set Context.

Click Person Name.

Select Person First Name.

Click Equal to.

Select Matches.

The default condition includes a literal field, but we want to change this to the string variable that holds the regular expression. When we change it, the editor automatically selects our variable, as it’s the only one defined in our rule.

Next to Matches, click the xyz button next to the literal field.

Select Change to variable.

At this point our rule will check the person first name for any special characters. Now we want to create two more similar conditions, one for the middle name, and one for the last name.

Click the down arrow above the first condition

Select Add condition.

Click the down arrow above the first condition

Select Add condition.

Click Person Name Character Set Context.

Click Person Name.

Select Middle Names.

Click the next Person Name Character Set Context.

Click Person Name.

Select Last Name.

We want to change the Equal to operators to Matches. And now we want to make sure our rule logic works if any one of the names contains a special character. So we need to change the And conjunction to Or. And then we need to change the literal fields to our pattern matching variable.

For the row containing Person Name.Middle Names, click the Equal to operator.

Select Matches.

For the row containing Person Name.Last Name, click the Equal to operator.

Select Matches.

Click the down arrow at the beginning of this condition group.

Select Change conjunction.

For the row containing Person Name.Middle Names, in the xyz value field, enter .*[!@$%\^&*()_+=|\<>?/]+.*.

For the row containing Person Name.Last Name, in the xyz value field, enter .*[!@$%\^&*()_+=|\<>?/]+.*.

We want to display an error message if the pattern matching finds any special characters. So in the next condition group we add an error message.

In the last row where the statement The variable value stringVar, click the down arrow at the start of this statement.

Select Add next.

Select Add error message.

In the Show an error message field, enter Person name cannot contain special characters.

Once we add that line for the message, we can delete the first default condition.

In the last row where the statement The variable value stringVar, click the down arrow at the start of this statement.

Click Delete.

Click Save and Close.

We’re now done creating the rule, so next we can test it. We’ll test our rule using the new hire flow. When we get to Person Details section, we’ll be sure to include a special character in one of the name fields. When we click Continue to exit out of this region, we get the error message.

Click the Home icon.

Click My Client Groups.

In the Quick Actions section, click Hire an Employee.

In the When is the employee hire date? field, enter today's date.

In the Legal employer list, select US1 Legal Entity.

Click Continue.

In the Last Name field, enter Smith%.

Click Continue.

Review the error message is the one you just created.

This concludes the demonstration of how to use pattern matching in an autocomplete rule.

Thanks for watching.

Oracle copyright and music.