How should a third part app update existing Request Item variables via API?

Jeff316
Kilo Guru

We have catalog items that generate REQ and Request Items in ServiceNow. We have a homemade third party app that knows the RITM number and needs to update variables on the RITM in ServiceNow from the home made application. Is there some oob API they can reference to POST updates to the variables of the RITM? What is the best way to have them update variables?

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

Sorry for Delayed Response:

 

Follow below process:

1) Create Scripted Rest API put PUT method.

2) Give them one Predefined JSON format in which you want data from them, which will have your ritm number as well..

3) So you will have to parse this RITM number in Scripted REST API and then glide record this RITM and update the variables.


See below script:

var obj = '';
obj = request.queryParams.number; // This is our Query param for Finding RITM in System, You will have number

var state='';
var status='';

var reqbody = request.body;
var reqdata = reqbody.data;

if(obj && obj!=''){

var inc = new GlideRecord('sc_req_item');
inc.addQuery('number',obj);
inc.query();
if(inc.next()){
inc.variables.variable_name = reqdata.parameter;//Parameter means the key in JSON
status = 'success';
}


THanks,
Ashutosh

View solution in original post

12 REPLIES 12

dave_edgar
Mega Guru

Yes.  I find the best way is to sent the sysID to the 3rd party app.  

You can use the api pages on the developer site to build a simple example

https://developer.servicenow.com/app.do#!/rest_api_doc?v=london&id=r_TableAPI-PUT

also you can use the REST API Explorer to test the code/payload you'd need to build]

https://<your_instance>.service-now.com/nav_to.do?uri=%2F$restapi.do

 

 

Hope that helps, if so please mark as correct or helpful

 
Dave

That's good. I can pass them the sys_id.

I already do send them all the variables in a POST to their system.

I just have no idea how to get a POST/PUT back from them to update the variables on the RITM record.

I looked at both scripted rest API and import API but all looks Greek to me until I can see one or figure out how to make one.

This is a first for me. 

I don't think I want them to directly update sc_item_option where the variable is stored.

If you can't get an api sent from the other system you could write a business rule to go GET any updates but that would put a lot of reliance on ServiceNow.  If you can get the other system to send out email updates you could write an inbound script to grab the updates and push them into the tickets

They have the ability to access ServiceNow via REST API.

I just don't know what to tell them to do, to update the variables on an RITM.