Custom Discovery Pattern to extract data from a list using eval in pattern step
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2024 08:58 AM
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>'
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: 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-03-2025 09:10 AM
I found the solution to my issue, I had to loop through the array of characters and write out the string.
EVAL(javascript: var rtrn = "";var array =${l_Serial};var i;for (i=0; i<array.size() ; i++) rtrn = rtrn + array.get(i); )