- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2020 11:48 AM
I'm trying to generate multiple RITM with a Record Producer and GlideappCalculationHelper API.
Script is not working. Nobody knows why?
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.sys_id.getValue(), <cat item id>, 1); // 1 is the qty
reqHelper.rebalanceRequest(current.sys_id.getValue());
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2020 11:43 PM
Best Way to solve this is use Service Catalog Script API to create both Request and RITM needed and then abort record producer to not generate a new boid request item.
Here is the code:
// cat_item sys_id
var CN = '43d255771b812010c01fff37dc4bcbcd';
// Create new chart
var cart = new sn_sc.CartJS();
// add item to char
var item =
{
'sysparm_id': CN,
'sysparm_quantity': '1',
'variables':{
<item variables>
}};
var cartDetails = cart.addToCart(item);
// Checkout Chart
var checkoutInfo = cart.checkoutCart();
// Redirect record producer to new request item
producer.redirect='sc_request.do?sys_id=' + checkoutInfo.request_id;
producer.portal_redirect='sp?id=sc_request&is_new_order=true&table=sc_request&sys_id=' + checkoutInfo.request_id;
// Abort new boid request creation
current.setAbortAction(true);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2020 04:16 AM
This script is running in a Record Producer.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2020 05:33 PM
Record producers run to task-based records for example incident, change, demand etc. It doesn't create request and requested items. Typically, it creates a record in the target table [task based] only.
If you don't have any specific configuration in place then this script shouldn't work as current object represents the target table which is not request table in the record producer's case. The method addItemToExistingRequest("request sysid", <cat item id>, 1) requires to have a Request sys id as a first paramter instead we are passing in the target records sys_id.
Can you expand and give some more details about the record producer so that we can help you better.
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2020 11:53 PM
Record producer is over de sc_request table so a Request is created automatically. Debugging you can see that a request sys_id is sent to addItem function. What you obtain debugging is that reqHelper object is not created after new instruction.
My goal is to generate automatically multiple request Items depending on record producer multi-row variable set heterogeneus values. Request will group diferent rows of the variable set in a unique homogeneus RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2020 09:59 PM
Have you tried making the quantity as a string - "1"?
Is this running on a scoped app or a global app? Scoped app does not support GlideappCalculationHelper
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.sys_id.getValue(), <cat item id>, "1"); // 1 is the qty
reqHelper.rebalanceRequest(current.sys_id.getValue());
Docs: https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/GlideappCalcHelperAPI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2020 12:40 AM
Tested. Not working