How can I read the ECC Queue payload parameters or Discovery Schedule fields in a Discovery Pattern?

Michal5
Kilo Expert

In one of our patterns I am trying to pass a 'Credential alias' value from discovery schedule directly to a pattern. Previously when I wanted to pass variables to a pattern, I would send them via discovery launch parameters. That works great for Serverless discovery schedules, but if I understand it correctly we don't have that option when 'discover' field is set to 'Configuration items'. The only way I managed to pass parameters was via Probe Parameters in the Horizontal Pattern record (discovery_probes) and I don't want to do that.

When inspecting some of the input payloads, I noticed that parameter 'computerSystem' is present - same as 'computer_system' temporary variable in the pattern designer. And the payload also has a 'credential_tag' parameter with a value I would like to retrieve.

Is there a way to retrieve either the 'credential_aliases' from the schedule or the 'credential_tag' value from the payload?

Thanks!

2 REPLIES 2

AbhishekGardade
Tera Sage

Hello Michal,

This may help:

var xmlString = "current.payload"; // gr.payload - you can specify payload here

var xmldoc = new XMLDocument(xmlString, true); // XML document is name space aware

var str = xmldoc.getNodeText("//credential_aliases"); // returns the node, str == "abcd1234"

 

Check out this document for detailed information:

https://docs.servicenow.com/bundle/newyork-application-development/page/script/server-scripting/conc... 

Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies

Michal5
Kilo Expert

Hi Abhishek,

the XMLDocument is helpful, but it's not exactly what I need. I am basically wondering if there is a way to get that information from the side of the mid server that runs the pattern. I have experimented with Javascript Probe script include, but so far without much luck, because it seems to be going server > mid server, not the other way around. Will update when I solve it.

Thanks!