11.2 Using the ECMAScript Editor

ECMAScript objects are supported only with servers that have Identity Manager 3.5.1 version. If a server in a selected driver set is earlier than Identity Manager 3.5.1, an error message is displayed, and Designer does not allow the object to be created. Change the version of the server to Identity Manager 3.5.1 on the properties of the server, then the ECMAScript object can be created.

Designer provides an ECMAScript editor, which also includes an ECMA Expression Builder. You use both to create the ECMAScript.

To access the ECMAScript editor:

  1. Right-click an ECMAScript object in the Outline view, then select Edit.

    or

    When creating an ECMAScript object, select the check box Open the editor after creating the object.

The ECMAScript editor provides different types of functionality depending upon which section you are using.

11.2.1 Main Scripting Area

The ECMAScript editor provides a main scripting area where the ECMAScript is created. You can type a new script, or copy an existing one.

Figure 11-1 Main Scripting Area

Using an Existing ECMAScript

  1. Open the ECMAScript in a text editor, then copy the script.

  2. Paste the ECMAScript into the ECMAScript editor.

  3. Press Ctrl+S to save the ECMAScript.

Editing an ECMAScript

  1. Right-click in the main scripting area, then select the desired option.

    Options for editing an ECMAScript object
    • Undo Typing: Undoes the typing that has occurred.

    • Redo: Redoes the last action.

    • Cut: Cuts the selected area.

    • Copy: Copies the selected area.

    • Paste: Pastes the information in the Clipboard into the main scripting area.

    • Delete: Deletes the selected information from the main scripting area.

    • Select All: Selects all of the information in the main scripting area.

    • Find/Replace: Finds and replaces the specified information.

    • Show Expression Builder: Launches the Expression Builder. For more information, see Section 11.2.2, Expression Builder.

Coding Help for ECMAScript

  1. Right-click in the left margin of the main scripting area, then select the desired option.

    Coding helps for an ECMAScript object
    • Toggle Breakpoints: To be implemented.

    • Enable Breakpoints: Set breakpoints in the ECMAScript.

    • Breakpoint Properties: View the properties of the breakpoints.

    • Add Bookmark: Places a bookmark icon on a line in the ECMAScript editor.

    • Add Task: Places a task icon in a line as a reminder of additional work that needs to be done. If you open the Task view from the toolbar, by selecting Window > Show View > Tasks, the task is displayed.

    • Show Quick Diff: To be implemented.

    • Show Line Numbers: Displays line numbers in the main scripting area.

    • Preferences: Sets the line delimitation and sets the suffix for the files created in the ECMAScript editor. By default, there is no translation for line delimiters, and the suffix is js.

11.2.2 Expression Builder

The Expression Builder helps in creating ECMAScript expressions. The Expression Builder can be accessed in two ways through the ECMAScript editor, it can also be accessed through the Policy Builder and the Argument Builder.

To access the Expression Builder in the ECMAScript editor:

  1. Right-click in the main scripting area of the ECMAScript editor.

    or

    Right-click the shell area of the ECMAScript editor.

To access the Expression Builder through the Policy Builder:

  1. Click the Launch ECMA Expression Builder icon next to the following actions or conditions:.

    • XPath expression

    • append XML element

    • append XML text

    • clone by XPath expressions

    • set XML attribute

    • strip XPath expression

To access the Expression Builder through the Argument Builder:

  1. Double click the XPath noun token.

  2. Click the Launch ECMA Expression Builder icon in the Argument Builder.

The Expression Builder has three panes; ECMAScript/Variables, Functions/Methods, and ECMAScript Operators.

Figure 11-2 Expression Builder

ECMAScript/Variables lists all of the current defined functions in the ECMAScript. Function/Methods contains the standard ECMAScript functions and the DirXML Script functions. ECMAScript Operators displays the standard ECMAScript operators.

To use the Expression Builder:

  1. (Optional) Click the desired ECMAScript/Variables.

  2. (Optional) Click the desired Functions/Methods.

  3. (Optional) Click the desired ECMAScript Operators.

  4. Click Check Syntax to validate the expression.

  5. Click OK to close the Expression Builder.

In the following example, the join ECMAScript variable is used with the NodeSet function or method, but there is no ECMAScript operator selected.

Figure 11-3 Expression Builder Example

11.2.3 Functions and Variables

As functions and variables are defined in the ECMAScript, they are displayed on the left side of the ECMAScript editor.

Figure 11-4 Functions and Variables

All of the variables that are stored in a function are grouped together. You can expand a function to view all of the variables, by clicking the plus icon (arrow icon in Linux). You can view the function without the variables by clicking the minus icon (arrow icon in Linux).

11.2.4 Error Display

As the ECMAScript is created, errors are displayed in the main scripting area and in the Problem view. The main scripting area displays the errors as a red X on the line where the error occurs.

Figure 11-5 Main Scripting Area Errors

The Problem view accumulates the errors as the ECMAScript is typed, displays the cause of the error.

Double-click the error in the Problem view. The cursor jumps to the problem line in the main scripting area.

To access the Problem view:

  1. In the toolbar select Window > Show View > Other > General Problems.

    The Problem view is displayed below the ECMAScript editor.

    Problem view

11.2.5 Shell Area

The shell area of the ECMAScript area allows you execute the ECMAScript. After the ECMAScript is created, you can test the functionality of the script.

Figure 11-6 Shell Area

Figure 11-6 contains an example of a function that determines the area of a circle. The function is tested by specifying a value of areaOfCircle(10). The shell displays the value of 628.3185307179587.

To execute the expression, press the Enter key. If you want to enter more than one line of code in the console, press Enter on the numeric-keypad.