How to call Server API within a pattern?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2018 01:44 AM
I have to do a gliderecord query to get data in one of the patterns. I have tried 'Set Parameter Value' with eval of the below javscript(formatted with \n here for better readability). GlideRecord does not seem to get processed, control always hits the else loop. The encoded query gives results when tried in UI so there is no issue with that. Same script works when I run it in background. Is there a package to be included to make GLideRecord work ?
javascript:
var rtrn = '';
var query = 'computer.name='+${computer_system.primaryHostname}+'^pid='+${process.pid};var gr = new GlideRecord('sometable');
gr.addEncodedQuery(query);
gr.query();
if(gr.next()){ rtrn = gr.port;}
else rtrn = '0';
rtrn;
- Labels:
-
Discovery
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2018 04:35 AM
Hi PN,
I believe the best option is to create a Custom Operation and put your script there. And then create a step from your Pattern using this custom Operation.
Would that work for your scenario?
See more details about creating Custom Operations here:
Regards,
Phillip
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2018 03:47 PM
Hey man, Custom Operations are really the way to go, however the Custom Operation step requires me to return a String and then choose a parsing strategy. What if I want a Custom Operation that just takes a table and returns a table, with no parsing needed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2018 11:29 AM
Hey Phillip , thank you for the link on custom operations. However I found out that the reason the API call failed in my pattern was because of the ACL on the table. The pattern I believe makes a REST call behind the scenes and it was using a user that did not have access on that table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2019 03:17 PM
PN:
Thanks! This approach cracked a big problem I was having in my Discovery Horizontal Pattern. It gave me the clue I needed to solve the issue.
Steven.