convertStringToList
A Workflow Engine function that converts a string of words separated by a defined character into a Javascript array (list).
You can use this function to overwrite the value of the source field with the resulting list or copy the resulting list into a given target field.
You can use any regular expression as the separator.
This function is available as a feature of the Add-ons v2.1 download and later. See Install Moogsoft Add-ons for information on how to upgrade.
This function is available for alert and enrichment workflows.
This function is available for event, alert, and Situation workflows.
Back to Workflow Engine Functions Reference.
Arguments
Workflow Engine function convertStringToList
takes the following arguments:
Name | Required | Type | Description |
---|---|---|---|
| Yes | String | Contains the original string. |
| No | String | Separator character that divides the values in the string. Default separator character is comma. |
| No | String | Destination field for the resulting list. Default is the field entered for sourceField. |
Example
The following example demonstrates typical use of Workflow Engine function convertStringToList
.
You want to convert the string "network :: database :: server :: operating system"
in custom_info.services
to a list and you want to overwrite custom_info.services
with the resulting list . Set the following:
sourceField
: custom_info.servicesseparator
: \s+::\s+targetField
: custom_info.serviceList
The UI translates your settings to the following JSON:
{ “sourceField”:”custom_info.services” } { “separator”:“\s+::\s+” } { ”targetField”: custom_info.serviceList }
If the source field does not contain any value or the separator cannot be used, then this function will return false
. Otherwise, the function will copy the following list [ "network" , "database" , "server" , "operating system" ]
into the given target field.