Command "setList" issue introducing variables from context

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Command "setList" issue introducing variables from context

L4 Transporter

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.

 

 

4 REPLIES 4

L5 Sessionator

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. 

 

Screen Shot 2022-12-05 at 3.18.00 pm.png

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.

 

L5 Sessionator

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. 

Thanks Fernandes, I like how it sounds. Join first the list, so it won't be treated as an array.

  • 1767 Views
  • 4 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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!