Pre-Post Processing Script - To perform lookup on a reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2025 05:08 AM - edited ‎04-03-2025 05:10 AM
Hello, I will start off by saying that my scripting skills are probably my weakest area in ServiceNow. I have a scenario where I have created a custom Discovery Pattern that is discovering an HP iLO (physical card installed on a server that allows remote management/console) via HTTP and creating an out-of-band device, this is working as intended. However, I would also like to perform a lookup against another table (potentially cmdb_ci_computer) and populate the host field on the cmdb_ci_outofband_device table. For example, if I am able to discover an HP ilo Device, name:hp_ilo and this device resides on a server, name:ilo_host. I would want to populate the hostfield in the screenshot with the server name. I believe this can be accomplished by a pre-post processing script. I am not exactly sure where to start or how to accomplish this. Thanks in advance for any advice or assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2025 10:46 AM
I pmed you the requested screenshots
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2025 10:53 AM
Hello @gagribben
I just saw the screenshot so the iloDeviceName that you have - is that the computer CI name ? Or is that computer CI's hostname ?
And you are searching in CMDB outbound table and updating it , that step you need to do via pattern step right? - the result that you want from script is just the sys_id of computer ?
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2025 11:03 AM
iloDeviceName was what you provided, I believe the associated variable in the pattern would be, sysName, and the Server in which the iLO is installed on is assigned to sysServer in the pattern.
The Pattern is creating a CI in cmdb_ci_outofband_device by the name i<servername> (i signifies the HP iLO naming convention) within the HP iLO ci that is created in cmdb_ci_outofband_device. the host field should represent the server that the iLO is installed on.
So I think what I am missing is I assign the variable in the pattern to the sysServer (the server the HP iLO is installed on) but its not being called in the script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2025 11:09 AM
Hello @gagribben
That was a demo script - which we provide for users to change per their requirement bade din our understanding.
Get the discovered HP iLO device name
var iloDeviceName = current.name; // CHANGE THIS LINE TO WHATEVER NAME INPUT YOU HAVE OF COMPUTER CI
// Lookup the server name in the cmdb_ci_computer table
var computerGR = new GlideRecord('cmdb_ci_computer');
computerGR.addQuery('name', iloDeviceName); //CHANGE HERE ALSO
computerGR.query();
if (computerGR.next()) {
return computerGR.sys_id.toString()
// }
Now this script will take input that you have of computer CI, use that input to find computer records in computer table and return you sys_id.
Now it depends on you how you want to use the returned output from here. You can put that in host or server whatever field you have.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2025 01:09 PM
Perhaps this can help, please read through all the replies..
https://www.servicenow.com/community/itom-articles/man-am-i-liking-this-http-classifier/ta-p/2325281
