- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
12-01-2022 01:58 AM
Hello,
We're using command "demisto.executeCommand("setList",{"listName":listName,"listData":listContent})" in order to introduce data in a json list. Where the "listName" is a json list name and "listContent" is data extracted from the context.
The issue:
The values introduced in "listContent" are like this example, "IPs" is a context variable that could be a single value or an array. And that's the main problem. If it's a single variable, it will be introduced like: "${Variable}":
{"value":{"IPs": "${Variable}"}
However, if it's introduced as an array, the " is no needed, so it will be: ${Variable}. With no comas:
{"value":{"IPs": ${Variable}}
So it's not possible to create the same command or task for both cases.
12-04-2022 08:23 PM - edited 12-04-2022 08:24 PM
Hi @Josep, The setList
automation is designed to overwrite the data inside the list. Could you try addToList
automation? It should work like shown in the screenshot.
12-05-2022 12:28 AM
Good morning Fernandes and thanks for your answer.
The purpose using "SetList" is to overwritre the data. First, we download all json to context, we manipulate it, then "SetList" commmand updates using the context the json, overwriting. However, sometimes the value of the key-value pair can be an array, so this causes a malfunction.
Normally it will be: {"${key}": "${value}"}
But with an array should be: {"${key}": ${value_array}}, with no "
So the point is how to use the same json value format for both cases.
12-07-2022 02:25 PM
Hi @Josep, the only option would be to merge\join the data before calling the setList command. You could try using the "Join" transformer. It will work with string and list inputs.
12-08-2022 11:20 PM
Thanks Fernandes, I like how it sounds. Join first the list, so it won't be treated as an array.
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!