Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to write loops in patterns?

PN5
Mega Contributor

I have list of entries in pattern table variable. The requirement is to loop through each table entry and run a command i.e. 'Parse Command output' and then store the result. How do I put a loop around a pattern step ?

5 REPLIES 5

doug_schulze
ServiceNow Employee
ServiceNow Employee

simple as running..

 

'command' table.value[*]

This will run the command for each entry in the table you created in the prior step.

Sorry Doug, thought I understood what you meant but tried this as well but below is not working, neither when I try it like

"certutil.exe -store "  + $CertificateStores.StoreName[*]

or

"certutil.exe -store "  $CertificateStores.StoreName[*]

Am I missing anything here??

find_real_file.png

Hey Patrick,

Yeah I was wrong on this one, thought it would be as simple as that but it isnt, it doesn't work that way.  I checked with the folks upstairs and seems you can (or have to) do this in a eval script.  If you take a look at the f5 BigIP LTM pattern, in the connections section at the bottom, step 23.1 is a good example of how to loop through a table (pools) and run the command you want from them...

 

find_real_file.png

 

 

Thanks Doug!

This indeed did it for me, using the CTX in a Transform Table to execute a shellCommand.

 

Cheers, Patrick