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 01:26 PM
What this sounds like is you have a request that has a list variable and the expectation is to generate requested items from that list. If this is correct, you may want to build a different Catalog Item that is hidden and is only launched from the first Catalog Item's workflow.
Rather than using addItemToExistingRequest, you can use the Cart API to generate the additional items from a script Workflow Activity. I have not validated this will work, but you could use something similar to the following:
var usrList = current.variables.user_list_variable;
var listArray = usrList.split(',');
var cartID = current.request;
var cart = newCart(cartID);
for (i = 0; i < listArray.length; i++) {
var item = cart.addItem('sys_id_of_new_catalog_item_here');
cart.setVariable(item, 'requested_for', listArray[i]);
//whatever else you have here
}
var rc = cart.placeOrder();
What I envision for the initial item is to have the above workflow activity, then to have the new catalog item have a different workflow that completes whatever is needed for fulfilling that one user in the list.
Let me know if this is helpful,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2021 09:49 PM
Thanks ccajohnson for your reply!
You understood my requirement correctly. Howevere the problem is, this script will generate request and RITM both. And my requirement is to associate the new RITM with the existing request record only.
Thanks!
V Sagar Mishra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2021 09:57 PM
post the creation of RITM you can update and associate the newly created RITM with the older REQ number
please share the script you are currently using
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-15-2021 10:42 PM
Thanks
I am using below script to create new RITM. But unfortunately it is creating Request as well. And if I will update the RITM's request field with existing request value. There will be orphan Request record in system.
var cartId = 'ac8996d61b9a24905c9b2f4aab4bcbf5'; //Existing request number
var cart = new Cart(cartId);
cart.addItem('69e04718dbc8ac100dfb144e1696198a', 1);
var rc = cart.placeOrder();
gs.print('Number# ' + rc.number);
Thanks
V Sagar Mishra