Active Questionnaire

 This widget renders a custom questionnaire and runs any JavaScript code on the server.


This widget can be used to configure a custom questionnaire, get the results and use them in a JavaScript code executed on the server.


Widget Parameters Overview


  • Questionnaire Definition - Contains the JS definition of the questionnaire using the SurveyJS library.
    • The title of this parameter contains the version number of the installed SurveyJS library.
  • Additional Survey Script - Contains additional script that should be executed in the survey itself like functions for custom actions.
  • Action JS Script - Contains the JS script that runs on the server after completing the questionnaire.


  • Progress Bar - Allows displaying a Progress Bar on the Top/Bottom of each page of the questionnaire.
  • Announce Successful Action Script Execution - Controls whether an information message is displayed after the successful execution of the Action Script.
  • Additional HTML - This HTML code is injected before the questionnaire itself. It allows to add HTML content, the ability to override the CSS styles, etc...


How This Widget Works

  1. The widget's configuration is loaded from the Questionnaire Definition widget parameter.
  2. The content of the Additional HTML widget parameter is processed and rendered.
  3. The questionnaire is then constructed and rendered.
  4. The user fills in the questionnaire and clicks on Complete on the last page.
  5. The client-side validation that's built into the questionnaire is executed.
  6. All answers and the Action JS Script widget parameter content are forwarded to the Polarion server.
  7. The Action JS Script is executed.
  8. Information about the script execution result is then returned to the client and rendered.

Since the questionnaire uses the SurveyJS library, it can be easily configured using a simple online editor at The last section of this description explains how the library can be updated. When done with the design and the configuration of the questionnaire, switch to the JSON Editor tab and copy all the code into the Questionnaire Definition widget parameter.

The final JS configuration code can be improved by using advanced settings and parameters described in the SurveyJS documentation. The documentation is available here:

One especially useful parameter is showCompletedPage: false. It forces the questionnaire not to display the final page with text so that it hides the whole questionnaire after successful completion. Using this option is recommended because it follows the use case criteria of a questionnaire on a Polarion LiveReport page. Another reason to use this parameter is that after the Action JS Script is executed on the server, the widget always renders info about the status of the execution. (You do not need the built-in final page.)


  pages: [
      name: "The Only Page",
      elements: [
          type: "text",
          name: "the_only_question",
          title: "The only question in this form."
  showCompletedPage: false

More examples of the questionnaire's configuration can be found here:


How to Install This Widget

  1. Download and unzip the packaged extension.
  2. Move folder binary/com.polarion.alm.activequestionnaire from the zip file com.polarion.alm.activequestionnaire_<version>.zip into: <Polarion Installation Folder>/polarion/extensions/.
  3. Remove folder <Polarion Installation Folder>/data/workspace/.config.
  4. Restart Polarion.


Detailed Parameters Description

Questionnaire Definition

In the widget properties, you find the version number of the currently loaded SurveyJS library behind the name of this parameter.

This widget parameter supports the usage of Velocity scripting. The JSON code that configures the rendered questionnaire can be fully or partially generated by Velocity. The context allows for access to all built-in objects (see section 10 of the Widget SDK for details) as well as all other custom Velocity Context plugins deployed on the Polarion instance.

The context also allows for access to other objects added by the Active Questionnaire widget:

  • $actionContext - RichPageWidgetRenderingContext of the widget
  • $page - RichPage - shortcut for $
  • $enumToJS - A helper class that generates JSON code from specific Polarion Enumerations or sets of Objects. Its full documentation is provided in a separate section below.

For Polarion versions up to 22 R2 (3.22.2), it is theoretically possible that users who can edit the configuration of this widget can elevate their permissions by using methods doAsSystemUser(...) or doAsUser(...) of ISecurityService. To prevent this, administrators can set the following widget configuration property in the file in the webapp folder of the extension:


This completely disables the ISecurityService with all its methods for the active questionnaire extension.

Additional Survey Script

This widget parameter supports the usage of survey scripting. You can register your function for the survey Instance. So, you can build in any fancy thing you ever missed in previous versions of the extension. Have a look at the example library to see what is now possible.

Example: Custom Validator

Content for Questionnaire Definition:

  "elements": [
      "type": "comment",
      "name": "memo",
      "isRequired": true,
      "title": "Type here text to pass the validation ",
      "validators": [
          "type": "expression", "text": "Your text should contains 'survey' word.",
          "expression": "MyTextValidator({memo}) >= 0"

Content for Additional Survey Script:

function MyTextValidator(params)
  var value = params[0];
  return value.indexOf("survey");
// Register the function for use in SurveyJS expressions
  .register("MyTextValidator", MyTextValidator);

Action JS Script

This widget parameter also supports the usage of Velocity scripting. For more details and the content of the Velocity Context, see the Questionnaire Definition widget parameter description above. Additionally, because the script from this widget parameter is run on the server, it also contains a JavaScript context with access to multiple JS objects. The built-in JS objects are:

  • trackerService - ITrackerService
  • projectService - IProjectService
  • scriptingUtil - ScriptingUtil
  • engine - RhinoScriptEngine (or Nashorn/Graal depending on your Polarion version and server setup)
  • context - SimpleScriptContext

The other JS objects added by the Active Questionnaire widget:

  • objectFactory - ObjectFactory of the Rendering API
  • actionContext - RichPageWidgetActionContext
  • page - ProxyRichPage - shortcut for $
  • transaction - WriteTransaction - shortcut for $actionContext.transaction()
  • surveyData - Contains a serialized version of the questionnaire's results. Further details are provided in the subsection below.
  • errorMessage - Empty by default - Allows for the forwarding of an error message back to the client. Enables server-side validation. If empty, the client does not throw an error. If not empty, it fails the completion process of the questionnaire and returns the message.
  • otherJS - Empty by default. The widget uses the context.executeJavaScript() method at the end of the JavaScript execution to return information about the status of the execution process. Setting a string value to this variable allows for the additional execution of any JavaScript code on the client after the execution of the JavaScript finishes.
  • survey – The execution of JS code on a client gives you access to the original survey JS object created at the time the questionnaire was first rendered on the Live Report page. It contains all the questionnaire data, its results, etc. - See the SurveyJS documentation for details. It also contains two variables added by the Active Questionnaire widget:
    • surveyResultId - Contains the ID of the <div> element used for rendering the result of the questionnaire's Action JS Script execution.
    • surveyDivId - Contains the ID of the <div> element used for rendering the questionnaire itself.

Example 1: Uses the questionnaire's <div> element to display additional information upon the script's successful execution.

var text = actionContext.getClass().toString();

Example 2: Executes JS on the client and displays an alert window with the id of the <div> element used for the rendering of the JavaScript execution result.

otherJS = "window.alert(survey.getVariable('surveyResultId'))";

Example 3: Accesses the answer to the questionnaire's question with ID the_only_question and displays it as a window alert on the client.

otherJS = "window.alert('" + surveyData.getAsJsonObject().get('the_only_question').getAsString() + "')";

surveyData Documentation

The content of surveyData is created by calling JSON.stringify() upon the JavaScript object with the results of the questionnaire and then forwarded as a String to the Polarion server. Next, the results are parsed and a JsonElement object surveyData is created. Specific values can be accessed with the getAsJsonObject() method and then used in the executed Action JS Script.

Example A: Get the Answer to "The Only Question"


Example B: Use answers to several questions to set up a new Work Item of the type Tool.

var projectId = page.getReference().projectId();
var project = trackerService.getProjectsService().getProject(projectId);
var typeEnum = trackerService.getDataService().getEnumerationForKey("WorkItem", "type", project.getContextId());
var enumOptT = typeEnum.wrapOption("tool");
var wiTool = trackerService.createWorkItem(project);
var toolTitle = surveyData.getAsJsonObject().get('question_title').getAsString().trim();
wiTool.setValue("version", surveyData.getAsJsonObject().get('question_version').getAsString());
wiTool.setValue("questionnaire", surveyData.toString());
wiTool.setEnumerationValue("environment", surveyData.getAsJsonObject().get('question_environment').getAsString());

Example C: Get the first of several answers to a question.



$enumToJS Velocity Context Extension

The active questionnaire widget introduces the following three helper methods to work with Polarion enumerations and objects.

$enumToJS.getEnumerationAsJS(String enumId, String wiTypeId, String projectId);


Provides the specified enumeration as JSON string for SurveyJS.


  • enumId: The enumeration ID.
  • wiTypeId: The Work Item type ID. If the parameter is empty, the method looks for general enumerations (i.e., not specific to a certain Work Item type).
  • projectId: The project ID. If the parameter is empty, the method looks for enumerations on the repository level.


 type: "dropdown",
 name: "question_environment",
 title: "What environment will the Tool be validated on?",
 description: "(list of values generated from the enumeration Environment)",
 $enumToJS.getEnumerationAsJS("environment", "", $page.getReference().projectId())

$enumToJS.getEnumerationWithDependencyAsJS(String enumId, String wiTypeId, String projectId, String dependencyEnumId, String dependencyFieldId);


Provides the specified enumeration including its dependency on the other enumeration as JSON string for SurveyJS.


  • enumId: The enumeration ID.
  • wiTypeId: The Work Item type ID. If the parameter is empty, the method looks for general enumerations (i.e., not specific to a certain Work Item type).
  • projectId: The project ID. If the parameter is empty, the method looks for enumerations on the repository level.
  • dependencyEnumId: The enumeration ID, the enumeration depends on. If this enumeration does not exist or there is no dependency on it, the enumeration without dependency is returned.
  • dependencyFieldId: The field ID/name in the SurveyJS JSON code of the other question this question depends on.


 type: "dropdown",
 name: "question_environment",
 title: "What environment will the Tool be validated on?",
 description: "(list of values generated from the enumeration Environment)",
 $enumToJS.getEnumerationAsJS("environment", "", $page.getReference().projectId())
 type: "dropdown",
 name: "question_method",
 title: "What is the method of validation?",
 description: "(list of values generated from the enumeration Validation Methods)",
 $enumToJS.getEnumerationWithDependencyAsJS("validation_methods", "", $page.getReference().projectId(), "environment", "question_environment")

$enumToJS.getObjectsAsJS(String objectType, String query, int limit, String sort, boolean renderWorkItemIdInTitle);


Provides the specified objects as JSON string for SurveyJS.


  • objectType: The object type name. Available values are Category, Document, Plan, Project, RichPage, TestRun, TimePoint, User, WikiPage, and WorkItem.
  • query: The query to specify which objects to return. If empty, the method returns all Objects of a specific objectType in the repository.
  • limit: The maximum amount of returned objects. If 0, it defaults to 200; Use -1 for an unlimited number of results. (Use with caution.)
  • renderWorkItemIdInTitle: Active only for objectType = "WorkItem"; Switches between two modes of enumeration option title rendering.


 type: "dropdown",
 name: "question_automates_system",
 title: "Which system will be used to automate?",
 description: "(list of values generated from a set of Work Items of type QSR Requirement Topic)",
 $enumToJS.getObjectsAsJS("WorkItem", "$page.getReference().projectId() AND type:qsrtopic", -1, "title", false)


How to Update the SurveyJS library

  • Get the desired version of SurveyJS for jQuery (e.g. from You should get the min versions to reduce the amount of data transmitted each time the extension is loaded. The files will need to have the names survey.jquery.min.js and survey.min.css.
  • Go to the Extension's location on the Polarion Server (e.g. [Polarion Root]/polarion/extensions/com.polarion.alm.custom.activequestionnaire/eclipse/
    ) and update the two files in the folder.


What's New in Version 1.2.1

Updated December 2022

1.1.2 - 1.2.1
Kevin Schmiechen (TUM-FSD) & Matthias Bittner (eRC-System GmbH)
- Added method $enumToJS.getEnumerationWithDependencyAsJS that provides a specified enumeration including its dependency to the other enumeration as JSON string for SurveyJS
Jochen Bärthlein (Siemens PLM)
- Added support for custom JavaScript code - register functions for advanced questionnaire functionality
- Added com.polarion.alm.shared.api.utils.velocity.ObjectFactory to ActionJS context
Kevin Schmiechen (TUM-FSD)
- Updated the included SurveyJS library to v1.9.55 - the currently installed version is now displayed in the widget parameter settings
- Added support for manual updating of the SurveyJS library (direct server access required)
- Added configuration property to optionally disable from the extensions Velocity Context to prevent permission elevation of users
- Polarion color scheme adaptation is now applied in the extension and not hardcoded in the SurveyJS library anymore
- Revised widget documentation/description
- The code was completely refactored for better maintainability
- Solved backward compatibility issues

1.1.1 - 1.1.2
- Fixed compatibility with log4j 2.*

1.0.5 - 1.1.1
- Updated surveyJS Library to version 1.8.75
- Added the testManagementService to actionsJs context

1.0.4 - 1.0.5
- Minor improvements and defect fixes



Vendor Siemens PLM
Published Version 1.2.1 - December 2022
Price Free
Community Supported Extension This extension is not supported by Siemens PLM.
Requirements Access to the server's file system
Polarion 20 R2 (3.20.2) and later

Last tested with Polarion 22 R2 (3.22.2)

Related Extensions