Supported JavaScript Data Types

Standard JavaScript data types are available, and Oracle Data Relationship Management uses them wherever possible. For example, dates are represented using the Date object. Functions are themselves objects, and a function invoked with new creates an object whose prototype points to the function's constructor prototype just as in any ECMA-compliant JavaScript environment.

Note:

JavaScript Document Object Model (DOM) objects are not supported in Data Relationship Management scripts.

You must be familiar JavaScript syntax and built-in objects, including what methods are available. Some of the available data types:

  • Array––Includes length, pop, push, concat, join, reverse, slice, shift, sort, and so on

    Note:

    Due to changes in the JavaScript boxing of items by caching mechanisms, not all Array functions will work as expected or as they did in previous releases. For example, indexOf in JavaScript will compare objects based on memory locations, not the string or text value of items. Therefore, other methodologies should be considered when inspecting arrays. IndexOf() uses "===" comparison in JavaScript and there is not a single definition of "==" that is available. You can use JavaScript design patterns to implement your own specialIndexOf() to provide a "=="-style comparison.

  • Boolean––Represents True and False

  • Date––Includes Date.parse(), month, day, year, and so on

  • Error––Uses try/catch error handling and access error.message

  • Function––Supports the standard call and apply functionality

  • Math––Includes random, max, pow, round, sin, cos, floor, sqrt, log, and so on

  • Number––All numbers in JavaScript are of the floating-point type number

  • RegExp––You can use language support for Regular Expressions or access them explicitly

  • String––Includes concat, indexOf, lastIndexOf, substr, split, splice, search, replace, toUpperCase, toLowerCase, and so on

Globally available functions like parseInt, parseFloat, isNaN, decodeURI, encodeURI are also available.

Print Function

The print function allows you to output debug information while creating scripts. The results are displayed in the Warnings section of the script editor. Although the print function produces only output in a testing context, the engine must still construct the arguments; therefore, comment out any print statements before saving a script for production use.

Format Function

The Format function provides a much richer string formatting mechanism than standard JavaScript. The first parameter is a string that contains format specifiers surrounded with curly braces. Escape braces by doubling them, for example "{{" becomes "{" in the output. Format specifiers start at zero and increase incrementally. If you omit a specifier from a sequence, the equivalent parameter to the Format function is ignored. For example, "{1}" ignores the first value parameter to Format and uses the second.

There is one shortcut. You can call Format and pass a format specifier without braces and pass only one argument. The result is equivalent to Format("{0:<specifier>", <argument>)

The format specifiers work similarly to other languages like Java or C#. The syntax is {<paramnum>} or {<paramnum>;<format>}, where paramnum is a positive whole integer starting at zero and increasing sequentially. The format param depends on the type of the object passed in as that parameter.

The format parameters generally return values appropriate to the user's locale; for example, in the US "{0:0.00}" returns "1.23" while in Europe it returns "1,23"). Alternately, you can use the escaping support to explicitly override the locale and output the same value for all users. For example, "#\,###\,##0" would format a number using commas as thousands separators in all regions, regardless of culture settings.