Creating a Rule to Update Required Option for Guardian
If the customer’s age is below 21, the name of the guardian becomes a required field. You can create a rule that updates the required option on the control
Guardian Name based on
Customer Age parameter value.
Procedure
Select the
Customer Age (CustAge) parameter from the Data node of
Outline view on the
Capture Claim form.
Click the
Rules tab on the
Properties view.
Click the
Add Rule button next to the event type
Update (update).
The
Rule Details dialog opens.
Type the following values for the input fields on
Rule Details screen and click
Next:
Name:
set_guardian_required
Label:
Guardian required when Age < 21.
Leave the
Update (update) event type in the
Rule: Pick Events dialog unchanged, and click
Next.
The
Define Actions dialog opens.
Click the
(plus) button .
The
Add Action to Rule dialog opens.
Select the radio button
Create a new action and then
Script Action.
Click
Next.
The
Enter the action details dialog opens.
Type the following values in the input fields, and click
Finish.
Name:
set_guardian_required
Label:
If customer age is less than 21, it will set the guardian field as required.
Type the following script:
context.form.logger.info('set_guardian_required: Customer age received:' + context.newValue);
var age = context.newValue;
control.GuardianName.setRequired(age < 21);
Click
Finish twice.
Note: You can test this rule by selecting a birth date that is less than 21 years ago from today.