Userscripts

ReqEdit Online Documentation

Userscripts

6 min read
last updated: 08/19/2026

Execute your own javascript scripts on the currently opened ReqIF document. Mass update attributes conditionally or based on other attributes.

TLDR; Jump to example script

Javascript automation

ReqEdit userscript editor window with javascript code

Notices and limitations

  1. The Javascript execution could produce unexpected results due to the fragile nature of Javascript engine
  2. Read only attributes cannot be updated
  3. If a value is invalid the attribute value will be empty
  4. HTML special characters will be converted to UNICODE so that   will be \u00A0, in regex replace use UNICODE character codes
  5. The javascript engine in ReqEdit is a basic javascript interpreter and does not have browser capabilities
  6. Updating a multi-object-type document can update all attributes values. Use the ReqEdit.ObjectType to limit what object type attributes to set

Script execution

The User scripts selector displays all the scripts found in ReqEdit scripts folder located at the current user’s %localappdata%\REQTEAM\ReqEdit\UserScripts\ folder.

From the editor window it is possible to quickly IMPORT and EXPORT these scripts.

The script selector is located at the right side of the toolbar

Select a script and then press to execute on all rows or to execute on only the selected row.

Run on document will be executed on each line from top to bottom according to the order in the hierarchy of the document.

Each row will have an index number represented by global.index variable (read on to find out more)

On each row you will be able to read all the columns and change them.

To save the changes to the current row use save(row)

Attribute type usage

TypeInformation
Booleanuse only the values: true, false without quotation marks
Stringupdate the value as “text in quotation marks”
Integerupdate with number
Dateupdate with a formatted string “yyyy-mm-ddThh-mm-ss
Enumeration single valuespecify the “value” case sensitive or “” to remove
Enumeration multi valuespecify as a “comma,separated” string case sensitive or “”
XHTMLupdate the value as “<strong>html codes</strong>”
Userscript attribute type usage

Javascript

Supports all ECMAScript 3 and ECMAScript 5 functionality, including ES5 strict mode

Read more about the supported Javascript features here Jurassic library

Variables

rowread/writeholds all attributes of the current row
row[“ID”] – read-only UUID
row[“ReqIF.ChapterName”] is the value
row[“ReqIF.ChapterName.type”] is the attribute type
row[“ReqIF.ChapterName.status”] is New, Edited, EditedAndSaved, Unchanged, Deleted, SoftDeleted
linksreadarray of link items
link[“type”] can be inlink, outlink, external
link[“source”], link[“target”] row item of the linked object
link[“uri”], link[“description”] external link metadata
link[“groupName”] for in/out links
hasChildrenreadtrue/false if the row has children or not
childCountreadnumber of child rows
globalreadmetadata of the current row or to be used to pass values between rows
global.indexreadthe number of the row in the selected rows starting from 1
global.levelreadthe level of the row starting from 1
global.statusreadthe status of the field: New, Edited, EditedAndSaved, Unchanged, Deleted, SoftDeleted
global.rowsreadthe total count of rows in the current selection, can be used to print log message only on the last row ex: global.rows == global.index
Javascript variables

Functions

log(string variable)display the contents of a single string variable to the output
save(row)IMPORTANT use this as the last line to save the row
show_form(formdata)display an automatically generated dialog form, the returned data can be used to change script execution. Read more on the dynamic forms section
Javascript functions

log(variable) calls will be collected and displayed at the end to the user. If the script editor is open the output messages are displayed in the bottom part of the editor

User script editor displaying output text

Dynamic forms

JSON defined dynamic dialog forms can be displayed from javascript.

var values = show_form({
  "title": "Table splitter",
  "fields": [
    { "name": "header_rows", "label": "Header rows", "type": "number", "min": "1", "required": true },
    { "name": "table_properties", "label": "Properties", "type": "text", "default": " width=\"100%\" border=1 " }
  ]
});
save(row);

Schema: title, description, fields[], submitLabel (alias: submitlabel), cancelButton (alias: cancelbutton).

Field types: number (int), string, text, boolean, options (string[]), label (plain text), html (rendered HTML preview).

Field properties

PropertyApplies toDescription
nameinput fieldsKey in the returned object (required for submittable fields)
labelallCaption; for label type, full-width descriptive text only
typeallSee field types above
min, maxnumberInclusive bounds (strings, parsed as integers)
requiredinput fieldsEmpty string/text/options fail validation when set
defaultinput fields, htmlInitial/submitted value for inputs; HTML body or document for html fields
optionsoptionsString array of dropdown choices

Fields without name, or with type label / html, are display-only and omitted from the return object.

HTML fields

Read-only HTML preview inside the dialog (type: "html"). Use for reports, formatted help text, or attribute previews — not for collecting user input.

ReqEdit uses System.Windows.Forms.WebBrowser (470×600). Field default supplies content. Save button exports to PDF or .html (Aspose.Words).

Rendering engine

The WinForms WebBrowser control hosts the legacy MSHTML (Trident / Internet Explorer) engine — not Edge, Chromium, or WebView2.

AspectBehaviour
EngineMSHTML / Trident (same family as ReqEdit XHTML grid cells)
Document modeIE7 by default — ReqEdit does not set FEATURE_BROWSER_EMULATION; an admin may override per-exe in the registry
Load methodDocumentText — in-memory HTML string, not a browsed URL
NavigationDisabled (AllowNavigation = false) — links do not open
ScriptsNot supported for forms; errors suppressed (ScriptErrorsSuppressed = true)

Preview therefore matches classic ReqIF/XHTML markup in the desktop app, not modern browser behaviour.

Supported HTML (practical)

Works wellAvoid / unreliable
div, p, span, brHTML5-only tags (section, article, …)
b / strong, i / em, u, sub, supFlexbox, grid, CSS variables
table, tr, td, th, thead, tbodyExternal CSS/JS from CDN or http(s) URLs
ul, ol, liES6+ JavaScript, modules, fetch
Inline style="..." on elementsSVG/canvas-heavy layouts
<object> attachments (ReqIF pattern)form, iframe, input, select, textarea
Simple <html><head><title>…</title><body>…</body></html>@media queries, web fonts (may not load)

Content rules for default:

  • Empty / missing → blank page (<html><body></body></html>).
  • Fragment without <html> → wrapped as <html><body>…</body></html>.
  • Full document containing <html> → loaded as-is.

name is optional; if present, the field is still not submitted. required has no effect.

Default values

Resolution order in ReqEdit dialogs:

  1. Field default in the form definition.
  2. Type fallback when no default is set.
TypeFallback when no default
numbermin if set, otherwise 0
booleanfalse
optionsfirst entry in options
string, text""

Use JSON booleans for checkbox defaults — default: true / default: false (not "true" strings).

Boolean single-choice pattern — model “pick exactly one” with multiple boolean fields. Set default: true on the first option; validate in script that exactly one checkbox is true:

function buildSingleChoiceFields(fieldPrefix, groupLabel, options) {
  var fields = [{ type: "label", label: groupLabel + " (select exactly one)" }];
  for (var i = 0; i < options.length; i++) {
    fields.push({
      name: fieldPrefix + "_" + i,
      label: options[i],
      type: "boolean",
      default: i === 0
    });
  }
  return fields;
}

ReqEdit dialog behaviour: WinForms dialog; field default pre-fills controls. Cancel returns {}.

Return value

Plain object keyed by field name. Types match field types (number → int, boolean → bool, others → string).

Example script

  1. Create a document by selecting File > New > New Archive …
  2. Select ReqEdit JS Demo template and save the file (the name is not important)
  3. Select the ReqEdit JS Demo script
    (If by any means the ReqEdit JS Demo script is not available create it manually, jump to create scripts and use the example script from below)
  4. Press Run on document
  5. Observe the change of the ReqIF-WF.CustomerStatus value to Accepted
  6. Read more in the the ReqIF Info panel
ReqIF Info panel describing the reqif template for the ReqEdit JS Demo

The script

Change a value conditioned by another value

if(row["ReqIF-WF.Type"] == "Requirement"){
	row["ReqIF-WF.CustomerStatus"] = "Accepted"
}
save(row);

Explanation

1.Using the if(<logical condition>){ … } control statement

2.Test the <logical condition> where ReqIF-WF.Type column value is equal to Requirement

3.If the logical condition is true then execute the code betwen { … }

4.Change the value of ReqIF-WF.CustomerStatus value to Accepted

5.Save the changes for the current row by calling save(row)

Without save(row) the changes are not applied to the document

Creating or modifying scripts

You can create new scripts by selecting empty on the script selector then pressing the edit button

Save the script with a descriptive name

The script will then be displayed in the dropdown automatically to be executed easily