Details
| ID | SetMultipleValues |
|---|---|
| Language | python |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10404775 |
| Tags | Utility |
README
Sets multiple key/value pairs to the context under a common parent key.
Script Data
| Name | Description |
|---|---|
| Script Type | python |
| Tags | Utility |
Inputs
| Argument Name | Description | Required | |||
|---|---|---|---|---|---|
| parent | The parent key to which we append all the other keys. | Required | |||
| keys | Separated list of keys separated by the specified delimiter (Comma is the default delimiter). | Required | |||
| values | Separated list of values separated by the specified delimiter (Comma is the default delimiter). | Required | |||
| delimiter | Delimiter by which the content of the values and keys lists are separated. Eg: “,” , “:”, “ |
”. Default is “,”. | Optional |
Outputs
There are no outputs for this script.
Example
Command
!SetMultipleValues parent=test_parent keys=key1,key2,key3 values=val1,valu2,val3
Context Result

import demistomock as demisto # noqa: F401 import pytest from CommonServerPython import * # noqa: F401 from SetMultipleValues import main @pytest.mark.parametrize( "args, excepted_result", [ ({"keys": "a,b,c", "values": "1,2,3", "parent": "Test"}, {"Test(true)": {"a": "1", "b": "2", "c": "3"}}), ( {"keys": "a:b:c", "values": "1:2:3", "parent": "Test", "delimiter": ":"}, {"Test(true)": {"a": "1", "b": "2", "c": "3"}}, ), ( {"keys": "a|||b|||c", "values": "1,|||2,|||3,", "parent": "Test", "delimiter": "|||"}, {"Test(true)": {"a": "1,", "b": "2,", "c": "3,"}}, ), ], ) def test_main(mocker, args, excepted_result): """ Given: - The script args. When: - Running the main function. Then: - Validating the outputs as expected. """ results_mock = mocker.patch.object(demisto, "results") mocker.patch.object(demisto, "args", return_value=args) main() assert results_mock.call_args[0][0]["Contents"] == excepted_result @pytest.mark.parametrize( "keys, values, expected_result", [ ( "array1,array2", '["1.1.1.1","8.8.8.8"],["test@gmail.com", "google.com"]', {"array1": ["1.1.1.1", "8.8.8.8"], "array2": ["test@gmail.com", "google.com"]}, ), ("array,val", '["1.1.1.1","8.8.8.8"], "test_val"', {"array": ["1.1.1.1", "8.8.8.8"], "val": "test_val"}), ], ) def test_arrays_as_values(mocker, keys, values, expected_result): """ Given: - The script args (values = string contains arrays) When: - Running the main function. Then: - Validating the outputs as expected. """ results_mock = mocker.patch.object(demisto, "results") args = {"keys": keys, "values": values, "parent": "Test"} mocker.patch.object(demisto, "args", return_value=args) main() assert results_mock.call_args[0][0]["Contents"] == {"Test(true)": expected_result}