From v2026.11, the code editors of mappings, interceptors and functions have a Generate Code button (the magic wand, before Compile & Test). It asks a few questions and writes ordinary code into the editor, which you can still change. The code is checked on the server before it is inserted.
What it can write
| Choice | What it does | Where |
|---|---|---|
| Translate values | Turns one value into another, for example IT becomes Information Technology, for the current value or a field of the record. | Mapping and function editors |
| Value by rules | Picks the value by conditions on the data, for example when Department is IT use Information Technology. The first rule that matches gives the value. | Mapping editors |
| Filter records | Includes only the records that match, or excludes them, by conditions on their fields (all conditions or any condition). | Interceptor editors |
For both value choices you also decide what happens when nothing matches: the value stays as it is, becomes a fixed value, or becomes empty. Conditions are: equals, does not equal, contains, does not contain, begins with, does not begin with, ends with, does not end with, is one of, is none of, is empty, is not empty. Text is compared ignoring case; a field with several values matches when any of them matches.
Generate code
- Open the mapping, interceptor or function code editor and click Generate Code.
- Choose what you want to do and fill in the values or conditions.
- Check Review your choice; Show code shows the code that will be inserted.
- When the editor already has code, choose Replace existing code or Add below existing code.
- Click Insert Code, then Compile & Test as usual.
On the Interceptors tab, Add with Filter opens the same questions to add an interceptor that keeps only some of the records; Add with Code adds an empty one.
Examples
A translation written for a mapping:
// Translate values, written by the code generator. Translates the current value: // "IT" becomes "Information Technology" // "HR" becomes "Human Resources" // Any other value stays as it is. var value = MSValue; return MSValues.Translate(value, value, "IT", "Information Technology", "HR", "Human Resources");
A filter written for an interceptor, keeping only the IT department's records with a company mail address:
MSItems.Keep(Items, x => MSItems.Is(x, "Department", "eq", "IT") && MSItems.Is(x, "Mail", "endsWith", "@monofor.com"));
The helpers the code uses
| Call | Does |
|---|---|
MSValues.Translate(value, otherwise, from1, to1, from2, to2, …) | The to of the first from that equals the value; otherwise when none does. |
MSValues.Is(value, op, compare) | Whether the value meets the condition. |
MSItems.Keep(Items, match) / MSItems.Exclude(Items, match) | Keeps or removes the records that match; returns how many were removed. |
MSItems.Is(item, field, op, value) | Whether a field of a record meets the condition. |
MSItems.Value(item, field) | The value of a field; "Manager.Name" reads a nested field. |