![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |
• Listen for changes in the value of Birth Date (BirthDate) parameter.
• Create a computation action that will compute age based on updates to the value of BirthDate parameter and Customer Age(CustAge) parameters. Since there is already a binding between Customer Age(CustAge) parameter and Age(CustAge) control, the Age control will be automatically updated with the computed value.
It is best practice to listen on parameter update events and modify the parameter values as part of rules that will propagate changes through bindings rather than directly updating the control values. This will avoid the need to write the form open scripts when parameter change events occur as part of form initialization.
1. Select the parameter Customer Age (CustAge) from the Data node of the Outline View on the Capture Claim form.
2. The Create Binding dialog opens.
3.
4. In the window Rule: Edit Computation Action, type following JavaScript code as part of an expression that computes the age based on the birth date specified:
5. Click Next.The Rule: Pick Events page opens.
6. The Select Event dialog opens.Figure 34 Select Event Dialog
7.
8. Click OK.
9. Click Finish.
Test your script by clicking the GWT Preview tab, specifying a value for the birth date, and pressing the Enter key. The calculated age will appear in the Age field.
1. Select parameter Customer Age (CustAge) from the Data node of Outline View on the Capture Claim form.
2. Click the Rules tab on the Properties View.Figure 35 Select the Event Type
3. Click Addbutton next to the event type Update (update).
The Rule Details page opens.Figure 36 Rule Details Page
4.
− Name: set_guardian_required
− Label: Guardian required when Age < 21.
5. The page Define Actions opens.Figure 37 New Rule Dialog, Define Actions Page
6. The page Add Action to Rule opens.
7.
8. Click Next.The Enter the action details page opens.Figure 38 Enter the Action Details
− Name: set_guardian_required
− Label: If customer age is less than 21, it will set the guardian field as required.
context.form.logger.info('set_guardian_required: Customer age received:' + context.newValue);
11.
This task is very similar to Task B: a rule is defined on event Exit (exit) of the controls Claim Amount (ClaimAmount) and Third Party Amount (ThirdPAmount) that will invoke a shared action round_value, which rounds to the nearest integer the amount specified as part of the control.
1.
2. Click the Rules tab.Figure 39 Claim Amount Control, Rules Tab
3.
4.
− Name: round_amount
− Label: Round amount to nearest dollar.
5.
6.
7. Select the radio buttons Create a new action and then the radio button Script Action and click Next.
8. In the Enter the action details page, type following values in the input fields.
− Name: round_value
− Label: Round the current value.
9.
context.form.logger.info('float value' + floatVal + ' and round value' + roundValue + ' are equal');
10. In the Define Actions page, select the Shared check box, which will make the action shared, and click Finish.
11. Edit the newly created rule and add an additional event by selecting the rule Round amount to nearest dollar in the Outline View, and then selecting the Events tab.Figure 40 Edit an Event
12. Click (plus)button and in the Select Event page select the event type Third Party Amount (ThirdPAmount), Update and click OK.
Figure 41 Round_amount Event Defined
This task creates a rule that displays a hint to a user when specifying the Claim Amount or Third Party Amount controls.
1.
2. Click the Rules property tab.
3. Click the Addbutton against the event type Enter (enter).
4. In the New Rule wizard, Rule Details page, add following inputs on the Rule Details screen and click Next:
− Name: show_rounding_hint
− Label: Display hint on entering claim amount controls.
5.
6. The Add Action to Rule page opens.
7.
− Name: show_rounding_hint
− Label: Display hint on entering.
9. Type this script and click Finish:
10.
11. Click Finish.
12. Edit the newly created rule and add an additional event by selecting the rule Display hint on entering claim amount controls in the Outline View, and then selecting the Events tab.
13. Click (plus)button and in the Select Event page select the event type Third Party Amount (ThirdPAmount), Update and click OK.
This will make the rule to be invoked on specifying both the controls Claim Amount and Third Party Amount.
As a result, whenever you specify data for the controls Claim Amount and Third Party Amount, the hint will be displayed.Note that the control Third Part Amount will be visible only if the third party was involved in the accident, which is not the case in this tutorial. In the step Set Third Party Information Pane we decided to make the Third Part Information pane invisible in case there is no third party involved in this accident.This task creates a rule that hides the hint created in the previous rule as part of Task D when exiting the Claim Amount or Third Party Amount controls.
1.
2. Click the Rules tab.
3. Click the Addbutton against the event type Exit (exit).
4.
− Name: hide_rounding_hint
− Label: Hide hint on exiting claim amount controls.
5. In the Rule: Pick Events page, leave the Exit (exit) event type unchanged in the Choose Events page and click Next.
6. The Add Action to Rule page opens.
7.
− Name: hide_rounding_hint
− Label: Hide hint on exiting.
9. Type this script and click Finish:
10.
11. Click Finish.
12. Edit the newly created rule and add an additional event by selecting the rule Hide hint on exiting claim amount controls in the Outline View, and then selecting the Events tab.
13. Click (plus)button and in the Select Event page select the event type Third Party Amount (ThirdPAmount), Update and click OK.
As a result, whenever you exit the controls Claim Amount and Third Party Amount, the hint will be hidden.This task creates a rule that displays the hint to user when specifying the description for the field Description in the Accident Information pane.
1.
2. Click the Rules tab.
3. Click the Addbutton against the event type Enter (enter).
4.
− Name: show_personal_injury_hint
− Label: Display conditional hint based on injury flag.
5.
6. The Add Action to Rule page opens.
7.
− Name: show_conditional_hint
− Label: Sets the hint based on PesonalInjury flag.
− Destination: Select the Hint property of the control Accident Description(AccDescription) in the Choose Destination page and click OK.Make sure that you have selected Show Controls and Panes as a filter in the upper right corner of the screen and click Finish.
10. Click Finish twice.
As a result of this rule, when option yes is selected for Personal Injury a hint will be displayed when specifying the Description value.
1.
2. Click thebutton against the event type Exit (exit).
3.
− Name: hide_conditional_hint
− Label: Hide hint on exiting claim amount controls.
4.
5. The Add Action to Rule page opens.
6.
− Name: hide_conditional_hint
− Label: Hide the hint.
− Destination: Select the Hint property of control Accident Description (AccDescription) and click OK.
− Destination: Select the Hint property of the control Accident Description (AccDescription) in the Choose Destination page and click OK.Make sure that you have selected Show Controls and Panes as a filter in the upper right corner of the screen and click Finish.
9. Click Finish twice.
In most cases, buttons on a form are configured with one of the pre-defined actions provided in TIBCO Forms. The left-most button on the Interview Witness form, for example, was created automatically when the form was generated. This button is configured with the standard rule Cancel that invokes the system action Cancel when the Cancel button is selected.However, the Interview Witness form also contains three custom buttons to control the flow of the business process:
• If the button labeled Failed - Try Again is clicked, the flow returns once again to the Interview Witness user task so that another attempt will be made to contact the witness.
• The button labeled Failed - Do Not Try Again and
• The button labeled Completed send the process to its end event.In this step, you will write the action scripts that control the functionality of these custom buttons. Table 4 shows three custom buttons and the action associated with the event Select - when the control is clicked or otherwise selected.
Table 4 Custom Buttons This action sets the witness_stat variable to a value of TRY_AGAIN, and then invokes the standard submit action that is defined by the system. This action sets the witness_stat variable to a value of FAIL, and then invokes the standard submit action that is defined by the system. This action sets the witness_stat variable to a value of SUCCESS, and then invokes the standard submit action that is defined by the system.The action defined for each of the three custom buttons invokes the standard Submit action that is defined by the system. Before doing so, each action defines the witness status by setting the value of the WitStatus control, which is used in the logic of the Contact Witness Again gateway to determine the flow of the business process. A value of TRY_AGAIN restarts the Interview Witness user task. A value of FAIL or SUCCESS moves the Claims Process business process to its end event.
1. Open the Interview Witness form in the Form Designer.
2. Click the Failed - Try Again button and view its Properties View.
3. Click the Rules tab on the Properties View.
4. Click the Addbutton against the event type Select (select).
5.
− Name: failed_try_again
− Label: Witness status = "TRY_AGAIN"
6.
7. The Add Action to Rule page opens.
8.
− Name: failed_try_again
− Label: Witness status = "TRY_AGAIN"
11. Click Finish twice.
1. Open the Interview Witness form in the Form Designer if it is not already open.
2. Click the Failed - Do Not Try Again button and view its Properties View.
3. Click the Rules tab on the Properties View.
4. Click the Addbutton against the event type Select (select).
5.
− Name: failed_dont_try_again
− Label: Submit with witness status = "FAILED"
6.
7. The Add Action to Rule page opens.
8.
− Name: failed_dont_try_again
− Label: Submit with witness status = "FAILED"
11. Click Finish twice.
1. Open the Interview Witness form in the Form Designer.
2. Click the Completed button and view its Properties View.
3. Click the Rules tab on the Properties View.
4. Click the Addbutton against the event type Select (select).
5.
− Name: success
− Label: Submit with witness status = "SUCCESS"
6.
7. The Add Action to Rule page opens.
8.
− Name: success
− Label: Submit with witness status = "SUCCESS"
10. Type this script this.getForm().getControl("witstatus").setValue("SUCCESS");
11. Click Finish twice.In this tutorial, you wrote a number of action scripts that enhance the functionality of the Capture Claim and Interview Witness forms. You learned how to create rules to compute age, update options, round amounts, display hints, hide hints, and so on.
![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |