Custom Discovery Pattern to extract data from a list using eval in pattern step

RGreene
Tera Expert

I have a custom pattern that pulls in data via an XML query via HTTP Get Call  the returned data is stored in Variables GetReturn2

Next with Parse Variable using parsing Delimited Text I extract t_Serial from GetReturn2 using Delimiters '<SN>''</SN>'
Screenshot 2024-10-08 104719.png

t_Serial ends up as a single line but is in list format.  This will cause a Java error because I will try to  store a List in a String Variable.  I need to store this in serial_number.
I tried to set Parameter value with the following code

EVAL(javascript&colon; var rtrn = "";var array = ${t_Serial};rtrn = array.join(" \n");)


But I do not seem to be bringing in the t_Serial value and endup with a null value when I attempt to store it to 
$cmdb_ci_outofband_device[*].serial_number.

 

I am assuming my EVAL line is wrong.  Any ideas on how to fix the EVAL line or a better way to do this.

 
 




1 REPLY 1

RGreene
Tera Expert

I found the solution to my issue, I had to loop through the array of characters and write out the string.

EVAL(javascript&colon; var rtrn = "";var array =${l_Serial};var i;for (i=0; i<array.size() ; i++)   rtrn = rtrn  + array.get(i); )