- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 05:05 AM
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?
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 11:19 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 04:57 AM
Thanks Ashu bro.. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2022 07:42 PM - edited ‎10-21-2022 02:39 AM
hi Ashutosh, thanks for this. Tried running it but it's not saving the value even in work notes
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var pathParams = request.pathParams;
var obj = pathParams.number; // [false]
var body = request.body.data;
if (obj && obj != '') {
var ritm = new GlideRecord('sc_req_item');
// ritm.addQuery('number', obj);
ritm.addQuery('sys_id', obj);
ritm.query();
if (ritm.next()) {
ritm.variables.u_name = body.variables.mgmt;
ritm.work_notes = "owrk"; //Parameter means the key in JSON
}
}
// return {
// "id": obj,
// "var": ritm.variables.u_name,
// "note": ritm.work_notes,
// "a": ritm.short_description,
// "test": ritm.variables.u_activity
// };
})(request, response);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 09:46 AM
PUT https://{instance}.service-now.com/api/sn_sc/servicecatalog/variables/{table_name}/{sys_id}
table name can what ever task you want to reference and sys_id is that task's sys_id
pass the variables in the body
{"var1":"val1","var2":"val2"}