To create a variable from a command's output, use dynamic outputs. Dynamic outputs are rules to extract a value or list of values from a command's output, such as for use later in the chain. You can add multiple dynamic outputs to a command using:
- An exact match, based on specific text at the start or end of values to extract
- Regular expression (regex), to match values based on a specific pattern or sequence
For example, if a command outputs a text file with values used with commands later in the chain, extract those values via a dynamic output for the File Utils connector's List File Content command.
Note: Dynamic outputs have a max string match size of 1024 characters. If the match exceeds this length then nothing is returned.
Test a dynamic output
To help ensure a dynamic output creates the desired result, test its criteria with sample values before you create it. For example, you can test a dynamic output with phone number data:
(381) 782-5259 (511) 545-6132 (220) 476-8339 (837) 516-4312
- In the chain, select the command with the output to extract from, and click Edit .
- Select Dynamic Outputs , and click Test.
- In Value to test, enter sample content indicative of the command output used with the dynamic output.
- Enter the regex or exact match criteria to use with the dynamic output. For example, to extract the area codes from the sample phone numbers:
- As Exact match:
- In Start and End, enter the opening and closing parentheses,
(
and)
, respectively. - To include the parentheses in the extracted value, select Include start and Include End.
- In Start and End, enter the opening and closing parentheses,
- As Regular Expression (regex) match:
- In Match type, enter the regular expression
\(([0-9]*)\)
, which matches digits between parentheses. - In Match result, enter
$0
to display the whole matched value including the parentheses, or$1
for only the matched digits without the parentheses.
- In Match type, enter the regular expression
- As Exact match:
- Click Submit, and verify the results match the desired output.
Create a dynamic output based on an exact match
- In the chain, select the command with the output to extract from, and click Edit .
- Select Dynamic Outputs , and click Add Dynamic Output.
- Enter a unique name to help identify the dynamic output.
- In Original output, select which of the command's outputs to extract from.
- In Match type, select Exact.
- Enter the text that indicates the start or end of the strings to extract, and select whether to include the matched text in the extracted value.
- To match text in only specific strings of the output, enter the lines to check.
- To include a range of lines, use a dash
-
, such as1-10
for lines 1 through 10. - To separate lines or ranges, use a comma
,
, such as1-10,13
for lines 1 through 10 and line 13.
- To include a range of lines, use a dash
- In Output type, select whether to extract a single value or multiple values.
Note: An output type of Multiple creates a JSON array of up to 1,000 items, which you can use with command or command group iterations.
- To consider character casing when matching text, select Case sensitive.
- To trim leading or trailing white space from matched text, select Trim matches.
- Click Save.
Create a dynamic output based on regular expression
- In the chain, select the command with the output to extract from, and click Edit .
- Select Dynamic Outputs , and click Add Dynamic Output.
- Enter a unique name to help identify the dynamic output.
- In Original output, select which of the command's outputs to extract from.
- In Match type, select Regular Expression (regex).
- In Match text, enter the regex syntax to use to match values to extract.
- In Match result, enter the syntax for how to display the matched value. For example:
- For the whole matched value, enter
$0
. - For the parenthesized matched value, enter
$1
.
- For the whole matched value, enter
- To match text in only specific strings of the output, enter the lines to check.
- To include a range of lines, use a dash
-
, such as1-10
for lines 1 through 10. - To separate lines or ranges, use a comma
,
, such as1-10, 13
for lines 1 through 10 and line 13.
- To include a range of lines, use a dash
- In Output type, select whether to extract a single value or multiple values.
Note: An output type of Multiple creates a JSON array of up to 1,000 items, which you can use with command or command group iterations.
- Click Save.
Delete a dynamic output
To remove a dynamic output from a command:
- In the chain, select the command with the output to extract from, click Edit , and select Dynamic Outputs .
- For the dynamic output to remove, click Delete .