Overview
The Code Editor is available anywhere in Etlworks where users can enter SQL, JavaScript, Python, or XSLT code. It supports full-screen editing, syntax highlighting, integrated macro/function insertion, and other developer-friendly features.
Opening the Code Editor
To launch the editor:
Click Open in Editor above any supported text field.
Or, when supported (e.g., in per-field mapping), click the editor icon directly next to the field.
Editor will open as a popup. You can:
-
Click Enter full screen to expand it.
-
Click Exit full screen to return to popup mode.
Code Editor Commands and Shortcuts
| # | Shortcut | Command |
|---|---|---|
| 1 | Ctrl+F | Search |
| 2 | Ctrl+Shift+F | Search & Replace |
| 3 | Click Line:Column | Go to Line |
| 4 | Click language selector | Select color highlighter |
| 5 | Click Enter or Exit Full Screen | Enter or exit full-screen mode |
Search & Replace
Go to Line
Changing the Language
At the right bottom corner of the Code Editor, you’ll find a language selector. It lists only the languages supported in the current context — for example, JavaScript, Python, SQL, or just one of them.
Changing the selected language:
-
Updates the syntax highlighting in the editor
-
Signals to Etlworks which execution engine to use
In some cases, like in mapping transformations, switching the language affects how the code is evaluated. For example, if you switch from JavaScript to SQL, the transformation will try to use native SQL on the destination side (if supported) to calculate the column value — instead of running JavaScript inside Etlworks.
This gives you full control over where and how the logic runs.
Code Tools: Macros and Functions
The Code Tools panel inside the Code Editor includes two tabs:
-
Macros (list of available macro + macro editor)
-
Functions (interactive function builder)
To show or hide the Code Tools panel, use the toggle at the bottom of the Code Editor popup.
Macros
A Macro is a reusable fragment of code in SQL, JavaScript, Python, Shell, or other supported languages.
Copying Macro to Editor
Click << button to open Copy Macro menu.
Actions:
-
Copy macro: Inserts {{MacroId:Label}} into the script
-
Copy body: Inserts raw macro code into the editor
When macro is inserted as a reference it will be displayed as below:
{{MacroId:Label}}
When the script is executed, the macro is expanded in place.
Creating a New Macro
1. Click Add Macro
2. Enter:
- Title (display name)
- Label (used in {{MacroId:Label}})
- Code
- Optional: Tags, Description
3. Click Save
Editing or Deleting a Macro
-
Click the 🖊️ icon to open the Macro editor.
-
Modify or delete the Macro from there.
Searching Macros
You can filter Macros by:
-
Name
-
Label
-
Tags
-
Description
Passing Parameters to Macros
Option 1: Use parent-scope variables
var data = 'Some long text';
{{ShortenData:Shorten data}}
Where macro code is:
data = data.substring(0, 7) + '...';
After expansion:
var data = 'Some long text';
data = data.substring(0, 7) + '...';
Option 2: Define reusable functions in macros
Macro:
function shortenString(str, length) {
return (str.length > length) ? str.substring(0, length - 3) + '...' : str;
}
Usage:
{{ShortenFn:Shorten function}}
var a = shortenString('Some long text', 10);
var b = shortenString('Another example', 20);
Functions
Functions are prebuilt, reusable logic blocks available in all supported languages (JavaScript, SQL, Python, etc.). Unlike Macros, Functions offer a more structured, interactive, and categorized way to discover and insert logic.
Click the Functions tab in the Code Tools panel inside the Code Editor.
You’ll see:
-
A Favorites section (only if you have functions marked as favorites)
-
A Category selector
-
A Search bar
-
A list of available functions grouped by category
Selecting Function
Click on a function name to expand it. You’ll see:
-
Full description
-
Actual code to be inserted
-
Optional tags
-
A list of input parameters (if the function requires any)
Below that, you’ll see a small form with input fields for each parameter.
You can:
-
Enter values for any of the parameters
-
Leave them blank (see behavior below)
Then click Copy Function to Editor to insert the function with all current values.
How Parameters Work
Each function can define one or more input parameters. These are placeholders for values like table names, expressions, field names, or format strings.
When inserting a function:
-
If you enter a value, it will be used in the generated code.
-
If you leave it blank and there is a default value, the default will be used.
-
If there is no default and no value entered, the parameter will be included in the code as a placeholder in double curly braces — like {{parameterName}}.
This allows you to insert the function structure now and fill in details later.
ExampleLet’s say a function has two parameters:
-
tableName (no default)
-
limit (default: 100)
If you leave both blank, the inserted code will look like:
SELECT * FROM {{tableName}} LIMIT 100;
If you enter customers as the table name but leave limit blank:
SELECT * FROM customers LIMIT 100;
If you enter both:
SELECT * FROM customers LIMIT 50;
Favorites
-
Click the ★ icon to add or remove a function from Favorites
-
Favorites are stored per browser using localStorage
-
If you have favorites, a virtual Favorites category will appear at the top
Filtering and Searching
-
Use the Category selector (e.g., Logging, Date & Time, Database Access) to filter the list
-
Use the Search bar to filter by:
-
Function name
-