Adding a Rule Function

See Rule Function Resource Reference for details on completing values.

Procedure

  1. In BusinessEvents Studio Explorer, right-click the folder where you want to store the rule function and select New > Rule Function. You see the New Rule Function Wizard.
    1. In the Rule Function Name field, type a name for the rule function.
    2. In the Description field, type a description. (In the source editor the description appears in the * @description line of the comments at the top of the editor).
    3. Set the return type for the rule function. Default is void. Browse to select a return type as needed. For return types that require additional configuration, such as ContainedConcept, complete the configuration in the Rule Function editor.
    4. If you want this rule function to be a virtual rule function (to be implemented by a decision table), select the Virtual check box.
      Note: You cannot change the name in the editor. To change the name of any project element, right-click the element in BusinessEvents Studio Explorer and select Refactor > Rename. See Element Refactoring Operations for more details.
  2. Click Finish. If you see the source editor, click the Form tab at the bottom of the editor to use the form editor as desired.

    At any time you can click the Form and Source tabs at the bottom of the editor to switch between the form-based editor and the source editor as you work, depending on your preference.

    Tip:
    Rule Function Editor Preference
     To set which mode the editor uses upon first opening, go to Window > Preferences > TIBCO BusinessEvents > Rules and select or deselect the desired check box: Initially show ’Form’ tab in Rule Function Editor.
  3. In the Form editor Configuration section, add or edit an alias and a description as desired. (In the source editor the description appears in the * @description line of the comments at the top of the editor and the Alias appears in the attribute list.).
  4. If you did not do so in the Wizard, use the Return Type to select the return type of the rule function.
  5. If you did not do so in the Wizard, set the Virtual check box according to your need. Select the check box if you are creating a virtual rule function (to be implemented by a TIBCO BusinessEvents Decision Manager decision table).
    Tip: In the source editor, the signature of a virtual rule function is:
       virtual void rulefunction folder.RFName

    Do not add code to the Body block in the source editor of a virtual rule function. If you do, you see error messages if you try to save or to switch to the form-based editor.

  6. From the Validity drop-down list, select the value that specifies where the rule function can be used (source editor attribute equivalents shown in parentheses):
    • Action (validity=ACTION)
    • Action and Condition (validity=CONDITION)
    • Action, Condition and Query (validity=QUERY)

      Virtual rule functions have a non-editable validity setting of Action.

  7. If the rule function returns a value, specify the Return Type, otherwise leave this field set to void. (Appears in the signature of the rule function in the Source editor.)

    Virtual rule functions have a non-editable return type of Void.

  8. In the Scope section (scope statements in the source editor) you define the arguments of the rule function. Drag entities into the Scope area from BusinessEvents Studio Explorer, or perform the following actions.
    1. Click Add to add resources that you will be using in your rule function. You see the Select Rule Function Scope Arguments dialog.
    2. In the upper half of the Select Rule Function Scope Arguments dialog, select the type you want to use.
    3. If you want to specify an array, select the isArray check box. (You can specify a variable array in the source editor in the usual way, for example, int[] myArr.)
    4. If the type you select is an ontology type, in the lower half of the dialog, select a resource from the filtered ontology tree.
    5. Click OK.

      Your selection appears in the list. TIBCO BusinessEvents assigns an alias to it. You can edit the alias.

      Add more entities as needed.

  9. Add more arguments as needed, and use the up and down arrows to order the arguments as needed.
  10. In the Body section (Body statements in the source editor), use the TIBCO BusinessEvents rule language to implement the function. (Virtual rule functions have only a signature, and no implementation at design time.)

    See Using Variables and Functions in the Rule Editor for more information on working in the rule editor.

  11. Save the resource.