Call a processor in REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2019 09:44 AM
I am new to REST API and processor.
Can the processor can be used as an alternative to REST API?
I created a demo processor and it is working fine, below is the code
Is there any way I can call this processor in a BR/rest API call?
(function process(g_request, g_response, g_processor) {
var name = g_request.getParameter("name");
//g_processor.writeOutput("text/html; charset=utf-8","This is a Test");
gs.info('processors'+name);
var gr=new GlideRecord('sys_user');
gr.addQuery("sys_id",name);
gr.query();
while(gr.next())
{
if(gr.country=="US")
{
g_processor.redirect('../hrportal?sysparm_domain_restore=false&sysparm_stack=no');
}
else
{
g_processor.redirect('../sp');
var ps=new GlideRecord('incident');
ps.initialize();
ps.short_description='test';
ps.insert();
}
}
/*if(!gs.hasRole('admin'))
{
g_processor.redirect('https://dev50540.service-now.com/hrportal?sysparm_domain_restore=false&sysparm_stack=no');
g_processor.writeOutput("text/plain", "Hello " + name);
}
else
g_processor.redirect('https://dev50540.service-now.com/home');
*/
})(g_request, g_response, g_processor);
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2019 06:22 AM
I think the better practice here would be to take whatever code you need to call from both the processor and rest api and put it in a script include, and then call that script include from either place.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 04:02 AM
Hi Brad
Thanks for the reply. Can we use Processor as an alternative for REST API? Can it be used for a Servicenow-Servicenow integration?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 05:09 AM
I would recommend you to go through the processor Docs and then you will get a clear picture about it. Where majorly Processors are used to build the custom URL
https://docs.servicenow.com/bundle/london-application-development/page/script/processors/concept/c_Processors.html
Suppose if you want to call Rest API multiple times then make use of script action concepts
Following links should be helpful:
ServiceNow to ServiceNow Integration
Servicenow to servicenow integration
Servicenow to Servicenow integration
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Regards,
Chalan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2020 12:58 AM
Hi Sanker,
Processors are deprecated now.
Scripted REST API can be used for ServiceNow-ServiceNow integrations.