- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
08-20-2024 01:19 PM
How do I combine commands on the #XSOAR command line?
If one command wants a list, I would like to call a list, not enumerate it on the command line.
For example, the RandomElementFromList works like this:
!RandomElementFromList count=1 value="banana, orange, potato" may randomly respond with "orange". Easy Peazy.
getList works like this:
!getList listName=fruitAndVegatables will respond with the entire list. Nice.
What if I have a long list named fruitAndVegatables stored and I want a compound command that will pick a value by combining the randomElementFromList command and the getList command? What is the syntax?
My guess is this, but it doesn't work:
!RandomElementFromList count=1 value=!getList listName=fruitAndVegatables
What combination of quotes, curly brackets and delimiters do I need? I am interested in the syntax. I did not see a relevant example.
Thanks
08-20-2024 11:08 PM
Hello!
To combine commands in Cortex XSOAR, first use !getList to fetch your list and store it in a context variable. For example:
!getList listName=fruitAndVegatables
Then, use !RandomElementFromList and reference the context variable:
!RandomElementFromList count=1 value="${fruitAndVegatables}"
Replace ${fruitAndVegatables} with the actual context key for your list. Ensure you use the correct variable name by checking the context after the !getList command.
08-20-2024 11:30 PM
In completion to the @John374McCray answer, you can use the extend-context parameter to ensure your context path is specific to that command (in case you use getList twice for example) : https://xsoar.pan.dev/docs/playbooks/playbooks-extend-context
08-21-2024 01:00 AM
Hey there,
just adding and summarizing what the other folks already shared....
The idea of running an a command within a command is not really forseen by XSOAR, I know you can do some magic with dt https://xsoar.pan.dev/docs/integrations/dt but not to the extend you are looking for.
So the best way forward is using the Context and keep manipulating it, basically running the commands in sequence
!getList listName=fruitAndVegatables extend-context=mylist
!RandomElementFromList count=1 value=${mylist}
or something along those lines 🙂
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!