Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 03:35 AM
var res = JSON.parse(producer.environment_selection); //multi row variable set
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
for (var i = 0; i < res.length; i++) {
var row = producer.environment_selection.getRow(i);
var item = cart.addItem('598e62ae1b79c254b0915287624bcbe4'); //item sysid
//environment selections variable set individual variables are below
cart.setVariable(item, 'select_environment', row.select_the_tier);
cart.setVariable(item, 'select_role', row.database_server);
cart.setVariable(item, 'match_type', row.database_instance);
cart.setVariable(item, 'access_level', row.access_level);
//user details
cart.setVariable(item, 'requested_for', producer.requested_for);
cart.setVariable(item, 'cost_center', producer.cost_center);
//catalog item variables
cart.setVariable(item, 'request_type', producer.request_type);
cart.setVariable(item, 'business_justification', producer.business_justification);
}
var rc = cart.placeOrder();
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', rc.sys_id);
ritm.query();
while (ritm.next()) {
ritm.request = current.sys_id;
ritm.u_requested_for = producer.requested_for;
ritm.setWorkflow(false);
ritm.update();
}
var req = new GlideRecord('sc_request');
req.addQuery('number', rc.number);
req.query();
if (req.next()) {
//gs.addInfoMessage(rc.number);
req.deleteRecord();
}
If two sets of variables are selected two RITMs are getting created but the problem is duplicates of variables are taking instead of unique one.
In the catalog item i'm using a single row variable set. Can anyone identify why it is creating duplicates.
Solved! Go to Solution.
1 ACCEPTED SOLUTION

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 04:34 AM
Hi,
As an FYI the 'Cart' script include has been deprecated and customers are strongly advised to move away from it. CartJS | ServiceNow Developers
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 04:34 AM
Hi,
As an FYI the 'Cart' script include has been deprecated and customers are strongly advised to move away from it. CartJS | ServiceNow Developers