Action Editor
A special Action editor is provided to help you create the code for your variable actions. You create the code by adding lines and then selecting commands and parameters from drop-down lists. This is a wizard-type editor that only shows objects which are relevant for the preceding object.
Action Basics
The Action Editor is designed for non-programmers but it is useful to know some basic concepts.
Command Statements
The first drop-down on a line of code contains commands (scroll down to see them all):
set: sets properties inside the document model
declare: declares local variables
execute: executes a function
if/else/else if/end if
AND
OR
return: returns a value
comment: adds comments to your actions
Although all the commands are always available, some commands are only relevant on certain lines and for certain action types. For example, you cannot start an On Change action with a return statement on line 1. If the command is not relevant, you cannot continue to write the line.
Objects and Properties
Commands affect objects (frame, page, layer, etc.) and properties that you can also select in drop-down lists.
Execute Functions
Typical functions as used in the examples in this section are:
selectItemName
applyFromColor
replaceRegExp
Hover over the drop-down lists to see an explanation in the tooltip.
Conditional Statements
Conditional statements are used to control when a specified function is executed. They can also help you create actions with less code lines.
if, else, else if, end if (to close if statement).
These statements are combined with the following operators:
is, is not, contains, starts with, ends with, <, <= , >, >=
& (to concatenate (join) strings), +, -, /, *
You will typically have a series of statements and one of these statements is executed if the condition is met.
Local Variables
Local variables are used for more complex calculations or if a calculation is used multiple times in the action code. First you need to declare the local variable and then you can start reusing in other variables.
You can see how local variables are declared and use in the following examples:
Action Editor Toolbar
Toolbar Tools
 
Creates a new line of code for the variable action. Hold down CTRL/CMD to add multiple empty lines below the current line.
 
Deletes the selected code line. Hold down CTRL/CMD to delete multiple empty lines below the current line.
 
Moves the code line up in the action editor. Hold down CTRL/CMD to move a line: one up, one down; to the top, bottom; x times up relative to the current position; to a specified line number.
 
Moves the code line down in the action editor. Hold down CTRL/CMD to move a line: one up, one down; to the top, bottom; x times down relative to the current position; to a specified line number.
 
Creates a duplicate of the selected code line immediately under the selected line. Hold down CTRL/CMD to duplicate one or multiple lines: one up, one down; to the top, bottom; x times down relative to the current position; to a specified line number.
Advanced Tools
Hold down the CTRL (Windows)/CMD (Mac) key while clicking the toolbar icons to display a dialog where you can perform advanced copying, deleting and moving, as explained in the Toolbar Tools table.
You can also copy a specified number of lines to the Document’s Action clipboard for reuse in the same action or in a different action of the same document.
NOTE: The contents of the clipboard is emptied when you close the document.
Copy action code to clipboard for reuse 
If you want to use the same action for multiple variables in the same document, you can copy the code to the clipboard and reuse it.
NOTE: You can only duplicate an action within the same document.
1 Press CTRL/CMD and click the Copy icon.
The Copy Lines dialog is displayed.
2 Enter the number of lines you want to copy to the clipboard.
3 In the Move drop-down list, select Document’s Action clipboard.
4 In the Name field, enter a name for this piece of code.
5 Click OK.
6 The new piece of code is added to the Paste Scrap list in the toolbar.
7 To add a saved piece of code to your action, select the name of the code in the drop-down list and click Paste Scrap.
The specified piece of code is added below the current line.
Regular Expressions
Some of the examples in this section use regular expressions. See “Form Validation” for code samples.
The following table gives an overview of the basic syntax for regular expressions.
^
matches the beginning of a string
$
matches the end of the string
[0-9]
any digit from 0 to 9
X{m,n}
m to n occurrences of X
X*
matches 0 to more occurrences of X
X+
matches 1 to more occurrences of X
X|Y
matches X or Y
()
groups the expression
/X/gi
the gi modifier does a global case insensitive search of all occurrences of X
Read this article on Wikipedia for more information about regular expressions or visit regex101 for a complete reference guide.
doc. version 6.0.4