- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
10-03-2023 03:44 AM - edited 10-03-2023 03:47 AM
Hello,
We are working on an automation which calls many different lists of nested dicts. Example:
upField:
0:
field1:value1
field2: value2
1:
field1:value3
field2: value4
In a playbook it will be easy to call only field1 using this expression: ${upField.field1} . It will create an array with these values:
[value1, value3]
However, if we want to get these values in an automation, a loop "for" has to be created to go over each dict of the list. Turning into a tedious, heavy and not flexible automation.
To avoid this, we tried unsuccessfully to use the commands "demisto.executeCommand("jmespath",{})" and "demisto.executeCommand("demisto.dt()",{})".
How can we achieve a simple command similar to "${}" in an automation?
10-03-2023 04:29 AM
Hi @Josep ,
Can you please try the below dt statement?
field1_values = demisto.dt(upField, 'field1')
I hope it solves your problem!
10-03-2023 04:29 AM
Hi @Josep ,
Can you please try the below dt statement?
field1_values = demisto.dt(upField, 'field1')
I hope it solves your problem!
10-03-2023 05:03 AM
You are the best @gyldz, it worked.
The nested dict was deeper, I show you the full commnand to solve it:
Data = demisto.get(demisto.context(),"Data")
field1_values = demisto.dt(Data, 'upField.midField.downField')
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!