GetValuesOfMultipleFields
The script receives a list of fields and a context key base path. For example, Key=Test.result List=username,user gets all of the values from Test.result.username and Test.result.user. The Get field of the task must have the value ${.=[]}.
python · Filters And Transformers
Details
| ID | GetValuesOfMultipleFields |
|---|---|
| Language | python |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10404775 |
| Tags | transformer |
README
The script receives a list of fields and a context key base path. For example, Key=${Test.result} List=username,user gets all of the values from Test.result.username and Test.result.user.
The Get field of the task must have the value ${.=[]}.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | transformer |
| Cortex XSOAR Version | 5.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| key | The JSON object under which to find the fields. For example ${Test.Results}. |
| list | The list of fields to retrieve from context. The list can contain comma seperated values. For example key1,key1 |
| value | The value to set in context for the key. |
Outputs
There are no outputs for this script.
import demistomock as demisto def update_list(_list: list, update_with): if isinstance(update_with, list): _list.extend(update_with) else: _list.append(update_with) def main(): args: dict = demisto.args() root = args.get("key") if root: if not isinstance(root, list): root = [root] keys: list = args.get("list", "").split(",") t: list = [] for obj in root: for _key in keys: temp = obj.get(_key) if obj else None if temp: update_list(t, temp) initial_value = args.get("value") if initial_value: update_list(t, initial_value) demisto.results(t) if __name__ in ("builtins", "__builtin__"): main()