SetWithTemplate
Common Scripts Pack.#
This Script is part of theSupported versions
Supported Cortex XSOAR versions: 6.5.0 and later.
Set a value built by a template in context under the key you entered.
#
Script DataName | Description |
---|---|
Script Type | python3 |
Tags | Utility |
Cortex XSOAR Version | 6.5.0 |
#
InputsArgument Name | Description |
---|---|
key | The key to set. Can be a full path such as "Key.ID". If using append=true can also use a DT selector such as "Data(val.ID == obj.ID)". |
template | The template text which can include DT expressions such as ${value}. |
template_type | The template type. |
append | If false, the context key will be overwritten. If set to true, the script will be appended to the existing context key. |
stringify | Whether to save the argument as a string. The default value is "noop". |
force | Whether to force the creation of the context. The default value is "false". |
context | The context data which overwrites the Demisto context. |
variable_markers | The pair of start and end markers to bracket a variable name. |
keep_symbol_to_null | Set to true to not replace a value if the variable is null, otherwise false. |
#
OutputsThere are no outputs for this script.
#
Getting StartedThe script builds a text from a template text which includes variables such as:
- This is a test message for ${user_name}.
The template will be formatted to This is a test message for John Doe.
by replacing variable parameters.
By default, a variable name starts with ${
and ends with }
. You can change the start marker and end marker by specifying the variable_markers
parameter.
#
Examples#
Replace variables in a text based on the context data.#
Command#
Lists LibraryTemplate:
#
Context Data#
Output#
Change the variable start and end marker to the windows command shell style such as %name%.#
Command#
Lists LibraryTemplate:
#
Context Data#
Output#
Change the variable start and end marker to the UNIX shell style such as $name.#
Command#
Lists LibraryTemplate:
#
Context Data#
Output#
Keep variable names if they are missing in the context.#
Command#
Lists LibraryTemplate:
#
Context Data#
Output#
Use DTs to build variables.#
Command#
Lists LibraryTemplate: