Skip to content

JavaScript Editor ​

The JavaScript Editor is the desktop Administrator's code editor for filter rules, transformer steps, channel scripts, and code templates.

The Web Administrator's script editor

The Web Administrator edits scripts in the Monaco editor. It completes object members as you type, offers the channel's own code template functions as completions, and is bundled with the web client, so it works without internet access. For writing scripts it is a far better experience than the desktop editor this page describes.

Features ​

Syntax highlighting ​

The editor provides color-coded syntax highlighting for JavaScript, including OIE-specific keywords and variables such as msg, tmp, connectorMap, channelMap, logger, FileUtil, DateUtil, and map shorthand functions ($c, $g, $s, $r, etc.).

Auto-completion ​

Press Ctrl+Space to open the auto-completion popup. It provides suggestions for:

  • Built-in JavaScript functions and objects
  • OIE utility classes and methods (ChannelUtil, DateUtil, FileUtil, DatabaseConnectionFactory, SMTPConnectionFactory, etc.)
  • Variable map methods (channelMap.put, globalMap.get, etc.)
  • Code template functions available in the current context

Auto-completion can also be triggered automatically after typing certain characters (. by default). These settings are configurable under Code Editor Preferences.

Find and replace ​

Ctrl+F (Cmd+F on macOS) opens the Find / Replace dialog:

  • Find text / Replace with: Search and replace fields with history dropdowns
  • Direction: Forward or Backward
  • Wrap Search: Search wraps around the end of the file
  • Match Case: Toggle case sensitivity
  • Regular Expression: Use regular expressions for search patterns
  • Whole Word: Match whole words only

Code folding ​

Collapse and expand code blocks:

  • Click the fold icons in the gutter (left margin)
  • Collapse functions, if/else blocks, loops, and other block structures
  • Use the Folding submenu in the context menu or keyboard shortcuts to collapse/expand folds

Context menu ​

Right-click in the editor to access:

OptionDescription
Undo / RedoUndo/redo recent changes
Cut / Copy / Paste / DeleteStandard clipboard operations
Select AllSelect all code in the editor
Find/ReplaceOpen the find/replace dialog
Find NextFind the next occurrence
Clear Marked OccurrencesClear highlighted search results
FoldingSubmenu: Collapse Current Fold, Expand Current Fold, Collapse All Folds, Collapse Comment Folds, Expand All Folds
DisplaySubmenu: Show Tab Lines, Show Whitespace, Show Line Endings, Wrap Lines
CodeSubmenu: Format, Toggle Comment
MacroSubmenu: Begin Recording Macro, End Recording Macro, Playback Recorded Macro
View User APIOpen the User API documentation

Keyboard shortcuts ​

Default shortcuts. On macOS most of them use Cmd where Windows and Linux use Ctrl:

Windows and LinuxmacOSAction
Ctrl+SpaceCtrl+SpaceOpen auto-completion popup
Ctrl+FCmd+FFind and Replace
Ctrl+GCmd+GFind Next
Ctrl+ZCmd+ZUndo
Ctrl+YCmd+Shift+ZRedo
Ctrl+/Cmd+/Toggle line comment
Ctrl+Shift+FCtrl+Shift+FFormat code
Ctrl+DCmd+DDelete line
Ctrl+JCmd+JJoin lines
Ctrl+[Cmd+[Go to matching bracket
Ctrl+ACmd+ASelect all
Ctrl + numeric keypad minusCmd + numeric keypad minusCollapse current fold
Ctrl + numeric keypad plusCmd + numeric keypad plusExpand current fold
Ctrl + numeric keypad divideCmd + numeric keypad divideCollapse all folds
Ctrl+Shift + numeric keypad divideCmd+Shift + numeric keypad divideCollapse comment folds
Ctrl + numeric keypad multiplyCmd + numeric keypad multiplyExpand all folds
TabTabIndent selected lines
Shift+TabShift+TabUnindent selected lines

The fold shortcuts use the keys on the numeric keypad, not the minus and plus keys on the main keyboard, so a keyboard without a numeric keypad needs them remapped. Every shortcut above except Tab and Shift+Tab can be remapped under Settings > Administrator > Code Editor Preferences using the Shortcut Key Mappings table.

Reference list ​

The Reference List panel sits next to the script editor and lists functions, code snippets, and variables by category. Use the Category dropdown to filter by category and the Filter field to search within the selected category.

Categories ​

The Category dropdown starts on All. A category appears only when it has items for the script you are editing, and User Defined Code and User Defined Functions appear only when code templates of that type apply to the current script.

The categories, with examples of what each holds:

  • Conversion Functions: Get Serializer, Convert XML to JSON, Convert JSON to XML
  • Logging and Alerts: log an info or error statement, send an email, trigger an alert
  • Database Functions: database queries and updates, and the connection template and driver name for each bundled driver
  • Utility Functions: reading and writing files, Base64, routing to another channel, attachments, hashing, DICOM images, pretty printing XML and JSON
  • Date Functions: parsing, formatting and converting dates, and getting the current date
  • Message Functions: the incoming message, raw or transformed, its type, version and IDs, iterating over and deleting segments, and removing destinations from the destination set
  • Response Transformer: setting the response status to SENT, QUEUED or ERROR, and its status message and error message
  • Map Functions: getting and putting values in each map, looking a key up in all maps, and creating a sent or error response
  • Channel Functions: the channel ID and name
  • Postprocessor Functions: the completed message and its merged, source and destination connector messages
  • User Defined Code: User-created code templates (code type)
  • User Defined Functions: User-created code templates (function type)

Rest the pointer on an item to see its description, then drag it into the editor to insert the code.

Variables ​

Which variables appear depends on the current script context. Examples include:

  • msg (inbound message in filter/transformer scripts), tmp (outbound template in filter/transformer scripts)
  • connectorMessage (in connector scripts)
  • message (completed message object in the postprocessor)
  • response, responseStatus, responseErrorMessage, responseStatusMessage (in response transformer scripts)
  • Map objects: connectorMap, channelMap, sourceMap, globalChannelMap, globalMap, configurationMap, responseMap
  • logger, router, alerts, replacer, contextFactory

Code editor preferences ​

Configure editor behavior in Settings > Administrator > Code Editor Preferences:

PreferenceDescription
Auto-Complete CharactersCharacters that trigger the auto-completion popup (default: .)
Include LettersIf enabled, auto-completion triggers after any letter is typed
Activation Delay (ms)Time to wait after typing a trigger character before showing the popup (default: 300 ms)
Shortcut Key MappingsTable of all remappable editor actions with their current keyboard shortcuts; double-click a shortcut to change it
Restore DefaultsReset all shortcut key mappings to their defaults