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 06:49 AM
Hello @gagribben
first, let me understand this straight, you already have the host which you ran a simple pattern step with that
This host field is it a cmdb_ci_computer table reference itself or host field from computer table reference ?
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 07:10 AM
@Shiva I provided a link in my initial post; this is the out-of-the-box cmdb_ci_outofband_device class. There is a field in the form called Host, which is a reference field to cmdb_ci_computer.
Currently I am creating a device in cmdb_ci_outofband_device for the HP iLO in which I am capturing the hostname of the HP iLO and some additional information, such as IP address and HP iLO URL. The only missing attribute at this time is the host (the server that has the Hp iLO installed on it.) Is missing from the cmdb_ci_outoband_device)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2025 07:19 AM
Yes @gagribben
I had read that and hence provided the script. However I just wanted to be on same page regarding the pattern steps that the reference must be of cmdb_ci_computer.
Then I am understanding correct. So you already have that hostname with you and with the script part you are looking in cmdb_ci_computer table - taking the sys_if and putting it in host field of outband ci. Yes correct replace the 2nd step.
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 10:20 AM
@Shivalika I attempted to use the post processing script and I am receiving an error " "message" : "2025-04-03 10:15:20: Post-sensor script \"Lookup Host Field on HP iLO\" failed due to: Abort executeJsScript due to invalid result format ""
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2025 10:32 AM
Share screenshot once @gagribben
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