Customize workflow scripts

You can edit project workflow scripts to customize the actions that you can perform, and the fields that are available to you in the user interface of Web Runner.

Note: Ensure you have the Set up Workflow permission to customize workflow scripts.

Overview

You edit project workflow scripts to customize the actions that you can perform and the fields that are available to you in Web Runner.

Example: You can control the following when you edit or submit defects:

  • Available fields

  • Required fields

  • Default auto-filled value of a field

  • The only one valid value of a field

Project workflow scripts are grouped by module. You edit a workflow script by adding JavaScript code to the events that are included in the workflow script.

Example: Under the Defects module script, you can edit the Bug_New event to customize user actions when a defect is submitted. For example, you can assign default values to required field when a defect is submitted.

Back to top

Considerations for cross project customization

If you are working in a template or linked project, the workflow scripts tree displays the following sections:

Template Scripts

Workflow scripts listed in this section are the scripts applied from the template to the linked project.

If you are working with a linked project, this section is displayed only when there are template scripts defined in the template. The template scripts cannot be edited in the linked project. If you remove a project from a template, the template scripts remain in the project and are editable.

The prefix Template_ is added to events in template scripts.

Project Scripts

Workflow scripts listed in this section apply only to the template or linked project in which you are working. Scripts of a template in this section of are not applied to linked projects.

When running workflow scripts for a linked project, ALM combines template and project scripts into one script. Duplicate variables or functions in the template and projects scripts can cause conflicts.

By default, ALM triggers template events. The project events is triggered if the template event does not exist, or if you instruct the template event to call the project event.

Each template event includes a commented call to the parallel project event.

Back to top

Edit scripts

To edit a workflow script, you add JavaScript code to event procedures that are triggered by user actions.

To edit a script:

  1. In the top right corner of Web Runner, click Settings > Customize.

  2. From the workflow scripts tree, under the node for the target module, select the script to which you want to add code, depending on when you want your code to be triggered.

    The Common script node contains scripts that are accessible from several modules.

    For detailed descriptions about event procedures, see Reference for ALM Events.

  3. Add your JavaScript code to the script.

  4. Click Save.

Back to top

SharedFunction event

You can define global variables or functions in the SharedFunction event. Scripts included in this event can be called by any other event.

If a script calls the SharedFunction event, the changes to the functions or variables of this event take effect in only the current script.

Back to top

Debug workflow scripts

You can debug a workflow script to resolve its errors.

To debug a workflow script:

  1. From the workflow scripts tree, select the workflow script.

  2. In the editor area, add the following statement:

    Copy code
    debugger
    console.log("<script_name> triggered")

    For example:

    Copy code
    function Bug_New() {
      debugger
      console.log("Bug_New triggered")
    }
  3. Press the F12 key to open the browser console.

  4. Trigger the script in ALM.

    For example, click the Create button in the New Defect window.

  5. Debug the script in the browser console.

Back to top

Limitations

The workflow scripts include the following limitations:

  • Not all objects or methods that are auto-suggested when editing script can be called. An error occurs if you call an unsupported object or method.

  • Some scripts listed in the workflow scripts tree are not available for use. They are displayed in gray.

See also: