Action commands
Action commands let you automate responses based on what respondents have already told you—or based on system variables and conditions you specify. Think of them as your survey’s autopilot: they work behind the scenes to capture data without asking respondents to lift a finger. These questions are typically hidden from view in live surveys.
You’ll know a question has an Action Command attached when you see a yellow scroll symbol next to it in the flowchart (Survey Editor (Legacy)), or an amber bolt icon on its card (Survey Editor (Beta)).
Available action commands
Section titled “Available action commands”Action Commands work with Single, Multi, Verbatim, Verbatims, and Grid question types. The commands available to you depend on which question type you’re working with—here’s the full lineup:
| Command | Description |
|---|---|
| COMBINE | Combines the answers of two or more identical questions into a single question |
| CONCATENATE | Concatenates the answers from two or more questions into a single string |
| DATEDIFF | Calculates the amount of time lapsed between two date questions |
| DATEPART | Enables the automatic capture of specific information based on a date variable |
| GET | Inserts the value of another single response or verbatim variable into a new question |
| MATHS | Handles basic mathematical operations within a question |
| QUERY | Queries an external database using SQL-style syntax |
| QUERYAPI | Connects to and queries an external API to insert a response |
| QUERYDS | Queries a datastore in the same subaccount as the survey |
| RANDOM | Enters a value at random based on specified minimum and maximum values |
| RECODE | Enters values based on specified rules |
| SET | Enters specified values into the question, without conditions |
| TRANSLATE | Translates a variable value into a specified language |
In Survey Editor (Beta), the Command Type list only shows the commands that work on the selected question type:
| Question type | Commands offered in Survey Editor (Beta) |
|---|---|
| Single, Verbatim, Verbatims | DATEDIFF, DATEPART, MATHS, QUERY, QUERYAPI, QUERYDS, GET, RANDOM, RECODE, SET, COMBINE, CONCATENATE, TRANSLATE |
| Multi | RECODE, SET, COMBINE |
| Grid | COMBINE, RECODE |
Set up action command
Section titled “Set up action command”Ready to add an Action Command? Here’s how:
- Add a Single, Multi, Verbatim, or Verbatims question to your survey flowchart
- Open the question’s menu
- Select Action Command
- In the Action Command dialogue box, select your Command Type
- Enter the action command syntax in the box. Remember to preface all question references with an
@symbol (e.g.,@Q1). If you need multiple commands, place each one on a separate line with a comma at the end. - Click OK
- Add a Single, Multi, Verbatim, Verbatims or Grid question to your survey flowchart
- Click the more icon (⋮) on the question’s card and select Action Command
- In Command Type, select the command
- Set up the command:
- Builder tab: fill in the fields. The builder writes the syntax for you, and shows a preview. DATEDIFF, DATEPART, GET, RANDOM, SET, TRANSLATE, COMBINE, CONCATENATE, MATHS and RECODE have a builder.
- Syntax tab: type the command, as shown in the syntax examples on this page. Click Copy to copy it, or Revert to undo your changes.
- Check any notes shown in the dialog. Red notes are errors that stop you saving. Many notes have a button that fixes the problem for you.
- Click OK, then save the survey
Check action command
Section titled “Check action command”To test your action command, preview the survey and verify it’s working as intended. Once you’re satisfied, check the Hide property so respondents won’t see the question.
Remove action command
Section titled “Remove action command”To remove an Action Command:
- Open the question’s menu
- Select Action Command
- Delete the action command syntax
- Click OK
The scroll symbol should no longer appear next to the object in the flowchart.
- Click the more icon (⋮) on the question’s card and select Action Command
- Click Remove
- Click Remove again to confirm
- Save the survey
The bolt icon should no longer appear on the question’s card.
COMBINE
Section titled “COMBINE”The COMBINE Action Command merges answers from two or more identical questions into a single question. Here’s a real-world example: imagine you’ve created two versions of the same question—one optimized for mobile, another for desktop. You can filter each by browser type, then use COMBINE to bring those answers together in a third (unfiltered) question.
The source and target variables must be identical in terms of question type and answer codes (though the question format and text can differ). Also important: source questions must be mutually exclusive—meaning any single respondent should only have answered one of them.
COMBINE Action Commands can be applied to Single, Multi, Verbatim, Verbatims, and Grid questions.
Setting up a COMBINE action command
Section titled “Setting up a COMBINE action command”To set up a question to combine the answers to two or more questions:
- Add a Grid Multi question to the survey flowchart, and enter the answers into the Quick Update Box. Alternatively, duplicate one of the source questions, making sure to edit question filters as required. The answer codes in all questions must match, but the answer labels do not need to be the same.
- Open the question’s menu
- Select Action Command
- In the Action Command dialogue box, select COMBINE in Command Type
- Enter the variables to be combined, prefaced with an
@ - Click OK
CONCATENATE
Section titled “CONCATENATE”The CONCATENATE Action Command joins answers from two or more questions into a single text string. Think of it as stitching together multiple responses into one cohesive piece of data.
CONCATENATE Action Commands can be applied to Single, Verbatim, and Verbatims questions.
Setting up a CONCATENATE action command
Section titled “Setting up a CONCATENATE action command”- Add a question to your survey flowchart and enter the answers in the Quick Update Box (if applicable)
- Open the question’s menu
- Select Action Command
- In the Action Command dialogue box, select CONCATENATE in Command Type
- Enter the variables to be concatenated, prefaced with an
@and separated by|(pipe) - Click OK
Concatenate syntax
Section titled “Concatenate syntax”| Target Variable | Concatenate | Explanation |
|---|---|---|
| Verbatim | @Q1|@Q2 | Inserts a text string concatenating the answers to Q1 and Q2, with no space between each |
| Verbatim | @Q1 |@Q2 | Inserts a text string concatenating the answers to Q1 and Q2, with a space between each |
DATEDIFF
Section titled “DATEDIFF”The DATEDIFF Action Command calculates the time elapsed between two date questions. Whether you need to know how many days passed between a shop visit and the survey completion, or the hours between two events, this command does the math for you.
DATEDIFF Action Commands can be applied to Single, Verbatim, and Verbatims questions.
Setting up a DATEDIFF action command
Section titled “Setting up a DATEDIFF action command”- Add a question to your survey flowchart and enter the answers in the Quick Update Box (if applicable)
- Open the question’s menu
- Select Action Command
- In the Action Command dialogue box, select DATEDIFF in Command Type
- Enter the Datepart (the unit of measurement), followed by the questions containing the beginning and end dates (prefaced with an
@) - Click OK
Datediff syntax
Section titled “Datediff syntax”DATEDIFF: {DATEPART},@STARTDATE,@ENDDATE
The result is the first date minus the second, so it’s negative when the first date is earlier. A date without a time counts from midnight.
| Target Variable | Datediff | Explanation |
|---|---|---|
| Verbatim | DAY, @SurveyEntryStartDateTime, @ShopDate | Inserts the number of lapsed days between the ShopDate and the time at which the respondent completed the survey |
| Verbatim | HOUR, @SurveyEntryStartDateTime, @ShopDate | Inserts the number of lapsed hours between the ShopDate and the time at which the respondent completed the survey |
Datediff datepart options
Section titled “Datediff datepart options”| Datepart | Description |
|---|---|
MILLISECOND | Number of milliseconds elapsed |
SECOND | Number of seconds elapsed |
MINUTE | Number of minutes elapsed |
HOUR | Number of hours elapsed |
DAY | Number of days elapsed |
WEEK | Number of weeks elapsed |
DAYOFYEAR | Gives the same result as DAY |
MONTH | Number of months elapsed |
QUARTER | Number of quarters elapsed. The result has the wrong sign, so use MONTH instead. |
YEAR | Number of years elapsed |
DATEPART
Section titled “DATEPART”The DATEPART Action Command automatically captures specific information from a date variable. The date might come directly from the survey (like a respondent’s date of birth) or from a system variable (like SurveyEntryStartDateTime, which records when the survey began).
DATEPART Action Commands can be applied to Single, Verbatim, and Verbatims questions.
Setting up a DATEPART action command
Section titled “Setting up a DATEPART action command”- Add a question to your survey flowchart and enter the answers in the Quick Update Box (if applicable)
- Open the question’s menu
- Select Action Command
- In the Action Command dialogue box, select DATEPART in Command Type
- Enter the Datepart (the unit of measurement), followed by the question containing the date (prefaced with an
@) - Click OK
Datepart syntax
Section titled “Datepart syntax”| Target Variable | Datepart | Explanation |
|---|---|---|
| Verbatim | MONTHNAME,@SurveyEntryStartDateTime | Inputs the name of the month from the survey start date |
Datepart options
Section titled “Datepart options”The following datepart options are available. Example results are based on @SurveyEntryStartDateTime = Dec 11 2021 1:28PM.
| Command | Example Result | Explanation |
|---|---|---|
AGE,@DOB | 43 | Respondent was 43 years of age at the time of the survey |
WEEKDAY,@SurveyEntryStartDateTime | Saturday | Survey was started on a Saturday |
DAY,@SurveyEntryStartDateTime | 11 | Survey was started on the 11th |
MONTH,@SurveyEntryStartDateTime | 12 | Survey was started on the 12th month |
MONTHNAME,@SurveyEntryStartDateTime | December | Survey was started in December |
MONTHNAME_SHORT,@SurveyEntryStartDateTime | Dec | Survey was started in December |
YEAR,@SurveyEntryStartDateTime | 2021 | Survey was started in 2021 |
YEAR_SHORT,@SurveyEntryStartDateTime | 21 | Survey was started in 2021 |
TIMEOFDAY,@SurveyEntryStartDateTime | afternoon | Survey was started after midday, and before 6pm |
TIMEOFDAY_FULL,@SurveyEntryStartDateTime | afternoon | Returns the full time-of-day label |
HOUR,@SurveyEntryStartDateTime | 01 | Survey was started after 1 o’clock (and before 2) |
HOUR24,@SurveyEntryStartDateTime | 13 | Survey was started after 1pm (and before 2pm) |
The GET Action Command pulls the value from another variable and inserts it into a new question. It’s perfect for capturing system data or referencing earlier responses.
GET Action Commands can be applied to Single, Verbatim, and Verbatims questions.
Setting up a GET action command
Section titled “Setting up a GET action command”- Add a question to your survey flowchart and enter the answers in the Quick Update Box (if applicable)
- Open the question’s menu
- Select Action Command
- In the Action Command dialogue box, select GET in Command Type
- Enter the variable to be inserted, prefaced with an
@ - Click OK
Get syntax
Section titled “Get syntax”| Target Variable | Get | Explanation |
|---|---|---|
| Verbatim | @CurrentDate | Inserts a time stamp into the question |
| Single | @LoopDriver1_CurrentAnswer | Inserts the code selected in the current loop iteration |
| Single | @LoopDriver1_Current | Inserts the loop iteration |
| Verbatim | @URL | Inserts the Survey URL into the question |
The MATHS Action Command handles basic mathematical operations within a question. Keep in mind it’s limited to 2 variables max—if you need to calculate with more, the RECODE Action Command is your better option.
MATHS Action Commands can be applied to Single, Verbatim, and Verbatims questions.
Setting up a MATHS action command
Section titled “Setting up a MATHS action command”To set up a Maths Action Command:
- Add a question to the survey flowchart, and enter the answers into the Quick Update Box where appropriate
- Open the question’s menu
- Select Action Command
- In the Action Command dialogue box, select MATHS in Command Type
- Enter the desired command (see examples below)
- Click OK
Maths syntax
Section titled “Maths syntax”MATHS: {OPERATION},{value},@VariableName
This stores the result of @VariableName OPERATION {value}. Either can be a number or a question. Include all three parts: without the question, nothing is stored.
| Operation | What it does |
|---|---|
ADD | Adds the value to the question’s answer. With a date, adds that many seconds. |
SUBTRACT | Subtracts the value. With a date, subtracts that many seconds. |
MULTIPLY | Multiplies by the value |
DIVISION | Divides by the value |
MODULUS | The remainder after dividing by the value |
Any other operation is treated as ADD. If both parts are dates with times, the result is the number of seconds between them.
| Target Variable | Maths | Explanation |
|---|---|---|
| Single - numeric | Division,100,@Q3 | Divides the response given to Q3 by 100 |
| Single - numeric | SUBTRACT,5,@Q1 | Subtracts 5 from the response given to Q1 |
The QUERY Action Command connects to and queries an external database using SQL-style syntax. Survey question codes can be referenced in the WHERE clause to filter results based on respondent answers.
QUERY Action Commands can be applied to Single, Verbatim, and Verbatims questions.
Query syntax
Section titled “Query syntax”SELECT {RESULT} FROM {TABLE} WHERE FIELD=@FIELD
| Parameter | Description |
|---|---|
{RESULT} | The column or value to return from the database |
{TABLE} | The table to query |
FIELD=@FIELD | Filter condition — @FIELD is a survey question code whose value is used in the query |
QUERYAPI
Section titled “QUERYAPI”The QUERYAPI Action Command calls an external GET API and inserts the response into the question. The URL can include survey field code values, letting you pass respondent answers as parameters.
QUERYAPI Action Commands can be applied to Single, Verbatim, and Verbatims questions.
QueryAPI syntax
Section titled “QueryAPI syntax”QUERYAPI: {URL}
| Parameter | Description |
|---|---|
{URL} | A full URL to a GET API endpoint. Can include survey field code values (e.g., https://api.example.com/lookup?id=@StoreCode) |
QUERYDS
Section titled “QUERYDS”The QUERYDS Action Command queries a datastore within the same subaccount as the survey and returns the first row that matches the filter criteria. It’s useful for looking up reference data — such as store details, location information, or any other data held in a datastore — based on a respondent’s answer.
QUERYDS Action Commands can be applied to Single, Verbatim, and Verbatims questions.
QueryDS syntax
Section titled “QueryDS syntax”QUERYDS: {DataStoreGUID},{ColumnName},{Filter}
| Parameter | Description |
|---|---|
{DataStoreGUID} | The GUID of the target datastore. Must be in the same subaccount as the survey. |
{ColumnName} | The name of the column in the datastore to return |
{Filter} | A filter expression to identify the row to return. Reference survey question codes with @. The first matching row is returned. |
QueryDS examples
Section titled “QueryDS examples”| Target Variable | QUERYDS | Explanation |
|---|---|---|
| Verbatim | abc123-guid,StoreName,storeid=@storeid | Looks up the StoreName column in the datastore where storeid matches the respondent’s @storeid answer |
| Verbatim | abc123-guid,Region,postcode=@Q1 | Returns the Region value from the datastore where postcode matches the answer to Q1 |
RANDOM
Section titled “RANDOM”The RANDOM Action Command generates a random value within the minimum and maximum range you specify. Perfect for randomization tasks or when you need to assign random values.
RANDOM Action Commands can be applied to Single, Verbatim, and Verbatims questions.
Setting up a RANDOM action command
Section titled “Setting up a RANDOM action command”To set up a Random Action Command:
- Add a question to the survey flowchart, and enter the answers into the Quick Update Box where appropriate
- Open the question’s menu
- Select Action Command
- In the Action Command dialogue box, select RANDOM in Command Type
- Enter the minimum and maximum values
- Click OK
Random syntax
Section titled “Random syntax”RANDOM: {MIN},{MAX}
| Parameter | Description |
|---|---|
{MIN} | Minimum value (can be a literal number or a survey variable prefaced with @) |
{MAX} | Maximum value (can be a literal number or a survey variable prefaced with @) |
RANDOM stores a whole number from MIN to MAX, including MIN and MAX.
| Target Variable | Random | Explanation |
|---|---|---|
| Single | 1,5 | Randomly selects one integer answer code between 1 and 5 |
| Single - numeric | 7500,12500 | Randomly selects an integer between 7500 and 12500 |
RECODE
Section titled “RECODE”The RECODE Action Command automatically enters values based on rules you specify. These rules can reference a previous survey question, a global survey variable, or be unconditional—you’ve got flexibility here.
RECODE Action Commands can be applied to Single, Multi, Verbatim, Verbatims, and Grid questions.
Setting up a RECODE action command
Section titled “Setting up a RECODE action command”To set up a Recode:
-
Depending on the data structure required for the recoded variable (the target question), add a Single, Multi, Verbatim, or Verbatims question to the survey flowchart and enter the answers into the Quick Update Box where required
Data Structure Required Single Multi Verbatim Verbatims Text/string? - - Y Y Numeric? Y - - Y Coded data? Y Y - - More than 1 possible answer? - Y - Y -
Open the question’s menu
-
Select Action Command
-
In the Action Command dialogue box, select RECODE in Command Type
-
Enter the action command syntax in the box, using the syntax examples below as your guide. Remember to preface all question references with an
@symbol (e.g.,@Q1). If you need multiple commands, place each one on a separate line with a comma at the end. -
Click OK
RECODE syntax
Section titled “RECODE syntax”Recode rules use Boolean logic. You’ll specify the clause as the value of the source question—when that’s true, it recodes to your specified value. You can also define what happens when the clause is false. If you don’t specify an “else” value, the recode will result in nulls for cases where the clause isn’t true. Separate multiple clauses with commas.
The syntax you need depends on two things:
- The question type of the variable that the recode rules will be based on (the source question)
- The data structure required for the recoded variable (the target question)
Simple recodes
Section titled “Simple recodes”| Source Variable/s | Target Variable | Recode |
|---|---|---|
| Single (Q1) | Single | WHEN @Q1=1 THEN 4 END, WHEN @Q1=2 THEN 5 END, |
| Single (Q1) | Multi | WHEN @Q1=1 THEN 4|1 ELSE 4|0 END, WHEN @Q1=2 THEN 5|1 ELSE 5|0 END, |
| Multi (Q1) | Multi | WHEN @Q1_1=1 THEN 4|1 ELSE 4|0 END, WHEN @Q1_2=1 THEN 5|1 ELSE 5|0 END, |
| Single (Q1) | Verbatim | WHEN @Q1=1 THEN 'Male' END, WHEN @Q1=2 THEN 'Female' END, |
| Multi (Q1) | Verbatim | WHEN @Q1_5=1 THEN 'Fifth answer selected in Q1' END, |
| Single - numeric (Q1) | Single | WHEN @Q1<18 THEN 1 END, WHEN @Q1>=18 THEN 2 END, |
| Verbatim - text (Q1) | Single | WHEN @Q1='Male' THEN 1 END, WHEN @Q1='Female' THEN 2 END, |
| Single Response Grid (Q1) | Verbatim | WHEN @Q1_1<5 THEN 'Less than 5 in first grid item' END, |
| Single (Q1 & Q1RANDOM) | Single | WHEN @Q1=4 then @Q1RANDOM else @Q1 end, |
| Verbatims | Verbatims | WHEN @Q1_1 is not null THEN 1|@Q1_1 ELSE 1|'No answer' END, WHEN @Q1_2 is not null THEN 2|@Q1_2 ELSE 2|'No answer' END, |
Multi condition recodes
Section titled “Multi condition recodes”| Source Variable/s | Target Variable | Recode |
|---|---|---|
| Single (Q1), Single (Q2) | Single | WHEN @Q1 = 1 AND (@Q2=1 OR @Q2=2) THEN 8 END |
| Single (Q1), Multi (Q2) | Single | WHEN @Q1 = 1 AND (@Q2_1=1 OR @Q2_2=1) THEN 8 END |
Recoding responses in a defined range
Section titled “Recoding responses in a defined range”| Source Variable/s | Target Variable | Recode |
|---|---|---|
| Single - numeric (AGE) | Single | WHEN @AGE>17 AND @AGE<25 THEN 2 END, |
| Single (NPS) | Single | WHEN @Q5<7 THEN -100 END, WHEN @Q5=7 OR @Q5=8 THEN 0 END, WHEN @Q5>=9 THEN 100 END, |
Creating an image reference for display in another question
Section titled “Creating an image reference for display in another question”| Source Variable/s | Target Variable | Recode |
|---|---|---|
| Single | Verbatim | WHEN @Animal=3 THEN 'tiger.png' END |
Concatenating text
Section titled “Concatenating text”| Source Variable/s | Target Variable | Recode |
|---|---|---|
| Single (Q1), Verbatim (ZooName) | Verbatim | WHEN @Q1=3 THEN 'Which animals did you see at ' + @ZooName + '?' END |
Recode based on count of answers
Section titled “Recode based on count of answers”| Source Variable/s | Target Variable | Recode |
|---|---|---|
| Multi (Q1) | Single | WHEN @Q1_Count>1 THEN 1 ELSE 2 END |
Calculating a total in a Multi Numeric question
Section titled “Calculating a total in a Multi Numeric question”| Source Variable/s | Target Variable | Recode |
|---|---|---|
| Verbatims - numeric (Q1) | Single - numeric | WHEN 1=1 THEN @Q1_total END |
| Verbatims - numeric (Q1) | Single - numeric | WHEN 1=1 THEN (Number(@Q1_1) + Number(@Q1_2) + Number(@Q1_3)) END, |
The SET Action Command enters specified values into a question without any conditions. It’s straightforward—you’re just setting a value, no logic required.
SET Action Commands can be applied to Single, Multi, Verbatim, and Verbatims questions.
Setting up a SET action command
Section titled “Setting up a SET action command”To set up a Set Action Command:
-
Depending on the data structure required for the recoded variable (the target question), add a Single, Multi, Verbatim, or Verbatims question to the survey flowchart and enter the answers into the Quick Update Box where required
Data Structure Required Single Multi Verbatim Verbatims Text/string? - - Y Y Numeric? Y - - Y Coded data? Y Y - - More than 1 possible answer? - Y - Y -
Open the question’s menu
-
Select Action Command
-
In the Action Command dialogue box, select SET in Command Type
-
Enter the variables to be set, prefaced with an
@ -
Click OK
Set syntax
Section titled “Set syntax”| Target Variable | Set | Explanation |
|---|---|---|
| Single - numeric | 0.25 | Inserts 0.25 into a numeric field |
| Single | 3 | Selects answer code 3 |
| Multi | 1,1,1 | Selects the first three answer codes in a Multi question, based on sort order (if randomised, the first 3 codes in the randomised set will be selected). If there are more than three answers to the question, the remaining answers will contain null values. |
| Multi | 1,1,1,0,0,0 | Selects the first three answer codes in a Multi question, based on sort order (if randomised, the first 3 codes in the randomised set will be selected). The remaining three answers will be given a value of 0 to tag them as not selected. |
TRANSLATE
Section titled “TRANSLATE”The TRANSLATE Action Command translates the value of a survey variable into a specified language, identified by a supported ISO language code.
TRANSLATE Action Commands can be applied to Single, Verbatim, and Verbatims questions.
Setting up a TRANSLATE action command
Section titled “Setting up a TRANSLATE action command”- Add a question to your survey flowchart and enter the answers in the Quick Update Box (if applicable)
- Open the question’s menu
- Select Action Command
- In the Action Command dialogue box, select TRANSLATE in Command Type
- Enter the variable to translate (prefaced with
@) and the target ISO language code, without quotes - Click OK
Translate syntax
Section titled “Translate syntax”TRANSLATE: @VariableName,LanguageCode[,isEVE,translatePrompts,useGoogleTranslate,openAIContext]
| Parameter | Description |
|---|---|
@VariableName | The survey variable whose value should be translated |
LanguageCode | A supported ISO language code (e.g., en-au, fr, de). Don’t put it in quotes: a quoted code makes the translation fail. |
isEVE | Optional. true if the variable holds an EVE conversation. Default false. |
translatePrompts | Optional. For an EVE conversation, true also translates what EVE said. Default true. |
useGoogleTranslate | Optional. true uses Google Translate (the default). false uses OpenAI. |
openAIContext | Optional. When using OpenAI, a short description of what the text is about. It can’t contain a comma. |
In Survey Editor (Beta), the TRANSLATE builder sets these with Variable, Language and More settings. A new command made in the builder uses OpenAI. TRANSLATE only runs on single-answer and text questions.
Translate examples
Section titled “Translate examples”| Target Variable | Translate | Explanation |
|---|---|---|
| Verbatim | @Q1,fr | Translates the value of Q1 into French |
| Verbatim | @OpenEnd,en-au | Translates the value of OpenEnd into Australian English |