RITM Created but Variables Not Populating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm creating RITMs using a scheduled job that processes entries from a staging table.
The RITM gets created, but no variables are visible in the "Item Variables" tab. All variable values are present in the payload and mapped correctly.
Any idea why variables aren't showing up in the RITM?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Share the screenshots of scripts and output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
// Creating RITM using CartJS
var cart = new CartJS();
var item = cart.addItem('cat_item_sys_id');
item.setVariable('requested_for', requester_sys_id);
item.setVariable('requester_name', requester_sys_id);
item.setVariable('openned_by', requester_sys_id);
.
.
.
item.setVariable('additional', additional_urls);
item.setVariable('action', action);
var requestSysId = cart.placeOrder();
When single payload of data is sent, it works. But when huge amount of data is being sent, It doesnt capture the values but creates a RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Huge amount meaning? are you talking about multiple RITMs ?
Try to use script in the below format instead of using setVariable, create an object (newItem)
var cart = new sn_sc.CartJS();
var newItem = {
"sysparm_id": "48ef0e6e2bca12d444a0f1996e91bf30", // Catalog Item ID
"sysparm_quantity": "1",
"variables": { //Below are variables and their values
"configuration_item": ci.toString(), // Passing CI sys_id
"requested_by": assignedTo.toString(), // Using assignedTo as the requester
"recipient": assignedTo.toString(), // Assigning the ticket to the same user
"short_description_new": shortDescription, // Custom short description
"description": descriptionValue, // Detailed description for the request
"serial_number": serialNumber.toString(),
"device_name": deviceName.toString(),
"model": model.toString(),
"assigned_to_user": assignedToUser.toString(),
"last_scan_user": lastScanUser.toString(),
"last_scan_date": lastScanDate
}
};
gs.log("New Item: " + JSON.stringify(newItem)); // Show the new item details
// Add the item to the cart and proceed to checkout
var cartDetails = cart.addToCart(newItem);
gs.log('Cart details added: ' + JSON.stringify(cartDetails)); // Show the cart details
// Proceed to checkout
var checkoutInfo = cart.checkoutCart();
// Now we use the request_id from checkoutInfo directly, no need to parse it as JSON
var requestId = checkoutInfo ? checkoutInfo.request_id : null;
gs.log('Newly created Request ID: ' + requestId); // Show the new REQ ID
Related Article - Understanding sn_sc.CartJS() in ServiceNow: Its Im... - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
share the complete code.
Did you check in backend table (sc_item_option_mtom) is variables are getting associated to that RITM?
If not then those won't be shown in variable editor.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader