Adding custom JavaScript functions to visual projects

You can use your own JavaScript functions in visual reports and dashboards with the help of JavaScript Modules.

About this task

You use the JavaScript Module editor with syntax highlighting to write and edit your own functions. To open the editor, select File > New > Other. In the New wizard, select QMF Objects > JavaScript Module.

After you have created a JavaScript Module, you can save it in a repository or file system, and then add it to a visual report or dashboard.

To add custom JavaScript functions to a visual project:

Procedure

  1. Open the Insert JavaScript Modules window. In the Project Explorer view, right-click the Globals node, and then select New > Insert JavaScript Module option.
  2. In the Insert JavaScript Modules window, decide whether you need to create a JavaScript Module or attach an existing one.
  3. If you decide to create a JavaScript Module, specify the required name in the JavaScript Module name field, select Create new, and then click Finish. The empty JavaScript Module opens in the separate editor window. Write the required JavaScript functions and close the editor.
  4. If you decide to attach an existing JavaScript Module, select Attach to an existing, and then specify the required module form a repository or file system. Click Finish.
    Note: You can view comments added in the JSDoc format to the script. These comments are visible to a user in the Expression Designer.
  5. You can view the attached JavaScript Modules in the Project Explorer view under the Globals > JavaScript Modules node.

Results

All the functions defined in the attached JavaScript Module can be found in the Expression Designer under the User node. You can use them as other expressions in your visual project.