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-04-2025 04:42 AM
Doug, I was actually following that article, which got me to the point I am now. It was extremely helpful when building the HTTP classifier and hitting the HP iLO API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2025 01:00 AM
Hello @gagribben , here is you Pattern pre/post script!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2025 05:03 AM
@Doci1 I am certainly willing to give it a try, this may be a silly question, but the pre processing script would be used in place of the post? I feel like I am not explaining the requirement properly. Let me show you an example of where I am and where I would like to be. There are 3 screenshots. The screenshot labeled Current shows the current CI that I am creating with the pattern, with the host name failing to be populated. The second screenshot labeled Desired shows what we would like to capture based on the value being captured and assigned to the variable in the pattern. The screenshot labeled Pattern, is the pattern where I am returning the desired value and assigning it to the sysServer variable in the pattern. I am having a hard time understanding how do we pass the variable in the pattern to do the lookup on the cmdb_ci_computer table and return the sysid based on the sysServer name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 12:21 AM
Hello @gagribben , my script does exactly what you have mentioned. You have the "sysServer" variable, in other term the host name. What you have to do is to find that record in CMDB, simply query CMDB for the hostname and get the sysID of the hostname. It is not working that you will simply provide the name of the hostname and SN will do the magic.
Therefore you have the Pre/Post script, where you can do all the logic. Query [cmdb_ci_computer], return sysID, provide it into cmdb_ci_outofband_device.host
Believe, I did the same for xCLarity last week 😉
Just mark my answers helpful if you will find them helpful please 😉
