RITM Insert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 04:18 AM
Hi, i want to inert RITM in my instance with populating the data on the variables of the catalog item that is there,
The parent ritm is getting created, now i want child ritms to get created but the values in want to populate are on the catalog item so i have to create ritm by populating the variables of the catalog item:
Script i am using:
var arrops2 = samplVal[i].split('|');
var cc = arrops2[0].toString();
var pt = arrops2[1].toString();
var cr = arrops2[2].toString();
var ue = arrops2[5].toString();
// gs.info(arrops2[i]);
gs.info("op0 " + arrops2[0]);
gs.info("op1 " + arrops2[1]);
gs.info("op2 " + arrops2[2]);
gs.info("op5 " + arrops2[5]);
gs.info('op</br>');
var rtm = new GlideRecord('sc_req_item');
rtm.initialize();
rtm.parent = current.sys_id;
rtm.request = current.request;
rtm.cat_item = current.cat_item;
rtm.variables.u_access_nuance_data_2 = samplVal[i];
rtm.variables.client_code = cc;
rtm.variables.patype = pt;
rtm.account = 'aditya';
rtm.variables.carrier = cr;
rtm.variables.u_account = ue;
var rtmsysid = rtm.insert();
gs.info('Insert' + rtmsysid);
Now what is happening that none of my fields are getting populated but a random field is getting populated in the catalog item variable that is visible on my ritm.
How to fix this ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 04:33 AM
You shouldn't be directly creating RITMs via GlideRecord due to their hierachical data model, and how flows/workflows attach. SN provide an OOB API to create requests (and the child ritm) https://developer.servicenow.com/dev.do#!/reference/api/xanadu/server/sn_sc-namespace/c_CartJSScoped...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2024 02:41 AM
But these cart api will generate a new request in the system as well and i dont wantthat i want to create ritm under one request and the 1st ritm of that request should be parent of the upcoming ritms.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2024 04:17 AM
Since you're seeing random fields get populated, it might be worth double-checking that the variable names in your script exactly match those in your catalog item. Typos or slight mismatches can cause that behavior.