Developer

@JAVASCRIPT

The JAVASCRIPT function is provided to allow JavaScript logic to be embedded within a rule definition. Included in the JAVASCRIPT function’s behavior is the ability to pass values to the script being processed from the rule definition. The value returned by the JavaScript logic will be the value returned by the function. This function takes one required parameter, and as many additional parameters as needed to pass in additional values. The supported return types of the JAVASCRIPT function are Boolean, integral number, decimal number, or string.

The first parameter to the JAVASCRIPT function is the JavaScript logic to be processed. This parameter may be any string value from any source within the application. In most cases, it is recommended that the rule term JavaScript Text is used, which is an available item within the rule editor. The main purpose for this term is that it provides a large text box control to display multiple lines of text, making it easier to write and edit JavaScript logic.

Additional parameters to the JAVASCRIPT parameter are referenced within the JavaScript logic through the zero-based array argv[]. This array is available in all JavaScript logic processed by the JAVASCRIPT rule function. The second parameter to JAVASCRIPT is stored in the argv[0] element, the third is in argv[1], and so on.

The data types of the additional parameters are strings. The parameters will be converted to this data type and will be passed to the JavaScript as such. These values can then be converted to a different data type where necessary within the JavaScript logic.

The JavaScript engine used to process the script logic is SpiderMonkey. Note that the Data Object Model (DOM) and the XMLHttpRequest object are not implemented as a part of this JavaScript support.

The usage of JavaScript within rule definitions is intended to be supplemental functionality. It is not recommended that all rules be written exclusively with JavaScript, as the processing of such script files is less efficient than the processing of rule definitions. The main intent is to allow a developer to implement certain pieces of logic using JavaScript wherever it is deemed appropriate to do so.

Parameters

    @JAVASCRIPT (JavaScript [, ..., ArgV String N])
  • JavaScript Required string parameter; contains the JavaScript logic to be processed by the JavaScript engine. In most cases, this logic will be contained in the special rule term JavaScript text, though any data term that may be safely converted to a string and that contains valid JavaScript may be used.
  • ArgV String N Optional string parameter(s); contains value(s) passed to the JavaScript and available in the argv[] array. The value of the second JAVASCRIPT parameter, i.e. ArgV String 1, is available within the array element argv[0], the next optional JAVASCRIPT parameter’s value is stored in argv[1], and so on. The members of this array are strings and should be converted within the JavaScript logic where necessary.

Supported Return Types

  • Boolean
  • Integral Number
  • Decimal Number
  • String