Cut, Copy, and Paste in the Rule Editor
The Rule Editor supports cut, copy, and paste operations for individual rule elements as well as for entire groups of conditions. This allows rule authors to reorganize complex rules quickly without manually re-creating repeated logic. Values can be pasted too, and are checked as they are pasted (see Pasting a Value below).
To select one or more rule elements:
- Use Ctrl + Click to select elements individually, or
- Use Ctrl + Arrow Keys to expand or reduce the selection in the direction of the arrow key pressed.
Once the desired elements are selected:
- Press Ctrl + C to copy the selection, or
- Press Ctrl + X to cut the selection.
Next, use either a mouse click or the arrow keys to move the selection to the rule element after which you want to insert the copied or cut elements.
If a group of conditions was selected, the entire group structure (including nested elements and logical operators) will be pasted as a complete unit. This makes it easy to replicate complex logic patterns across different branches of the same rule.
Example Workflows
- Reorganizing rule flow: Select a group of related conditions and move them to a different branch of the rule.
- Duplicating a sub-expression: Copy a condition or group and paste it under another part of the rule that requires similar logic.
- Template-based authoring: Copy a core group once and reuse it throughout the rule instead of re-creating it manually.
Pasting a Value
When a value box is open (a string, or a number the user types), the same keys work on its text, as in any text box: Ctrl + V pastes, Ctrl + C and Ctrl + X copy and cut the selected text, Ctrl + A selects all of it and Ctrl + Z undoes. They do not touch any rule elements selected before. On macOS, Cmd works in place of Ctrl, and pasting from the browser's context menu works the same way.
A pasted value goes through the same checks as a typed one, so the clipboard is not a way around the settings of a field or parameter. It is one more guardrail that keeps a rule valid while it is written:
- A string value is limited to the maximum length of its field or parameter (the
Max of its Field or Parameter attribute).
- A numeric value is pasted only when the value it makes is a number its field or parameter allows. Otherwise nothing is pasted, the box keeps the value it had, and the Help bar says why:
- a decimal separator in a whole-number field, such as an
int or a long: This field does not allow decimal values;
- a minus sign where the field's
Min is not below zero: This field does not allow negative values;
- anything else that is not a number, such as text, a second separator, an exponent like
1e5 or a space inside the number: This field accepts numeric values only.
- Spaces around a pasted number are ignored, a period and a comma are both accepted as the decimal separator, and a value that starts with a separator gets its leading zero (
.5 becomes 0.5), exactly as when it is typed.
The server still validates the whole rule when it is saved; the value box stops a wrong value earlier, at the moment it is entered.
Copying a Rule as Text
The editor's getRuleText() method returns the whole rule as the editor shows it, in plain text: each element's label in order, one space apart, its new lines as line breaks and its indentation as tab characters. An unfinished rule is returned as it stands. Use it to put a rule on the clipboard, in an email, or in a ticket, for example from a button of your own:
await navigator.clipboard.writeText($ce("divEditor").getRuleText());
In the Rule Repository, every rule editor has a Copy icon in its top-right corner that does exactly this.
Mobile Devices
Cut, Copy, and Paste operations are currently not supported on touch devices when using gesture interactions.