Skip to content

Function Editor

Introduction

In Wized all dynamic fields are powered by functions. A dynamic field is any field that can change based on user input or other factors. For example, the following fields are dynamic:

  • The text of an element that is populated from an API response.
  • The visibility of an element that is based on a user's input.
  • The body of a request that is populated from the user's selections.

What's a Function?

A function is a piece of code that takes some input and returns some output. For example, the following function takes a number parameter as input and returns the number multiplied by 2:

js
(number) => {
  return number * 2;
};

In the case of Wized all dynamic fields are powered by a function that takes predefined parameters and expects an output. For example, the following function is used to dynamically populate the user's name in a text element:

js
(c, f, i, n, r, v, e, t) => {
  return r.load_user.data.name;
};

The Function Field

Function fields look like this in the configuration panels: Function Field

When clicking on a function field box, the Function Editor panel will open providing you a full code editor experience: Function Editor

Autocompletion

The Function Editor provides autocompletion for all parameters. This means that when you start typing a parameter, a list of available values will be shown. For example, when typing v. a list with all available variables will be shown:

If you want to manually open the autocompletion list, you can press Ctrl + Space on your keyboard.

Keyboard Shortcuts

The Function Editor uses VS Code's editor under the hood, which provides a lot of useful keyboard shortcuts. Here are some of the most useful ones:

ShortcutDescription
Ctrl + XCut line (empty selection)
Ctrl + CCopy line (empty selection)
Alt + ↑ / ↓Move line up/down
Shift + Alt + ↓ / ↑Copy line up/down
Ctrl + Shift + KDelete line
Ctrl + EnterInsert line below
Ctrl + Shift + EnterInsert line above
Ctrl + Shift + \Jump to matching bracket
Ctrl + ] / [Indent/outdent line
Home / EndGo to beginning/end of line
Ctrl + HomeGo to beginning of file
Ctrl + EndGo to end of file
Ctrl + ↑ / ↓Scroll line up/down
Alt + PgUp / PgDnScroll page up/down
Ctrl + GGo to Line...
Ctrl + FFind
Ctrl + HReplace
Ctrl + DAdd selection to next find
Alt + ClickInsert additional cursor
Ctrl + UUndo last cursor operation
F2Rename variable