Dynamic Outputs are rules that create variables from Command outputs. The rules are configured to selectively extract a single value or a list of values by using an exact string match or regular expression (regex). These rules provide a powerful way to quickly and easily extract text that can be used in other areas of a OneCloud Chain. All output types are supported, and it is possible to add multiple Dynamic Output rules to a single Command.
To create a Dynamic Output, please follow these steps:
- Add a Command such as List File Content that produces an output.
- Edit the Command and navigate to the Command Output tab (fourth tab with a lightning bolt).
- Set the Name of the variable.
- Select the Orginal output type (the list is based upon the output of that particular Command).
- If using Exact, enter the Start and End string to match as well as the option to Include start and Include end.
- If using Regular expression, then set the Match Text and Match Result.
- In both cases, optionally set the Lines to check. Separate with commas and specify ranges with a - (i.e. 1-10).
- Set if the desired result should be a Single value or Multiple values in the form of a JSON list.
- For Exact match, optionally toggle Case sensitive and Trim matches to eliminate white space.
Add a Dynamic Output by selecting the blue button at the bottom of the interface and use the trash can icon to the right of the Orginal Output dropdown to remove a particular rule.
Pro Tip: Extracting values from a text file
If there is a file, such as a log file that contains values that need to be set as OneCloud variables, use the List File Content command and the Dynamic Outputs to get and set the variable value(s).
From within the Dynamic Outputs editor, the string matching rules can be tested to ensure that the text capture is configured correctly. In the following example, the following list of telephone numbers is tested with a regular express:
(381) 782-5259 (511) 545-6132 (220) 476-8339 (837) 516-4312
The following regular expression is used in the Match Text, which isolates and groups multiple digits between parathesis:
The Match Results returns the value of the group.
In the following example, notice that switching the Output type from Single to Multiple allows multiple values to be selected.
Dynamic Command outputs can be set to be a single value or multiple values. If multiple is selected, an array list variable is created with a maximum of 1000 items. Dynamic Outputs that use multiple values can be useful with Command and Command group iterations.
Learn about Variable Transformation.