Adding new RITM to existing Request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2021 09:51 AM
Dear Experts,
I want to add new RITM in my existing requests. To achieve this, I am using " reqHelper.addItemToExistingRequest()" to add a new RITM in my existing Request.
But the problem is, I am unable to find the actual RITM which is being created. The method addItemToExistingRequest does't return any values.
Also tried to get the most recent created or updated RITM, but its failing as mutiple RITM is being created at same time due to automation. And while copying the variable, it is updated the same RITM again and again as their timestamp is same most of the time. As a result most of the RITM have no value in their variables.
Requirement - Need to add a new RTIM on the request once a specific RITM is closed successfully. And the request contains one RITM for each users seleceted in perticular list variable.
For Instance: If 10 user is sleceted in the list, 10 RTIM will get created(Same catalog item with different variable and short desc). Once any of the RITM is closed, new RITM(Other Catalog Item) should be added with the same details which got closed.
Any help is really appriciated.
Thanks
V Sagar Mishra
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2021 10:51 PM
Hi,
that is how the Cart API behaves.
It would create REQ and RITM both
You can delete that Orphan REQ post it's creation. That is the only way.
Or another way is
1) create RITM from script
2) Then link the variables with the values for those RITM by creating records into these 2 tables
sc_item_option_mtom and sc_item_option
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2021 06:54 AM
Based upon the thread, it appears that the cart API is not behaving as you would expect. Since you want to add additional items to an already existing request, it looks like the addItemToExistingRequest method should work. However, what I have found is the method will create the item and associate it with the request, but it will not populate the variables. What you may have to do is use the addItemToExistingRequest method, but then add the appropriate variable values. In the example I have below, I have two users (Abel Tuter, Abe Lincoln) to which I generate two items. I then search for those generated items and populate the requested_for variable for each.
var usrList = 'a8f98bb0eb32010045e1a5115206fe3a,62826bf03710200044e0bfc8bcbe5df1';
var listArray = usrList.split(',');
var catID = 'a13ed8362f5e2010576f837cf699b658'; //use whatever catalog item you use
var reqID = 'f1321e1b3b101300088d832b44efc40a'; //use current.request when in a workflow
for (i = 0; i < listArray.length; i++) {
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(reqID, catID, 1);
}
var itmQry = new GlideRecord('sc_req_item');
itmQry.addQuery('request', reqID);
itmQry.addQuery('cat_item', catID);
itmQry.query();
var chgCount = 0;
while (itmQry.next()) {
itmQry.variables.requested_for = listArray[chgCount];
itmQry.update();
chgCount++;
}
A few caveats:
- It may be best to have a different catalog item than the original parent so that you can populate the variables without overwriting the original parent item record.
- You may want to have some sort of wait condition in the workflow for those that are generated so that it can proceed once the variables are populated.
Please let us know if your are successful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2022 04:39 AM
If you're looking for a way to achieve adding a new catalog item to an existing request with the CartJS API have a look at this Article: