
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 07:08 AM
Hi Everyone,
Have a question, trying to use GlideappCalculationHelper to add 2 request item to an existing request but my script doesnot seems to work... It is not creating additional items. Can anyone help on this or give anyother way of doing it. I used this link https://community.servicenow.com/thread/184740 .Below is my script :-
function onAfter(current, previous) {
if(current.variables.bundle == 'corporate_standard') {
for(var i=0; i<2; i++) {
// add item to current request
gs.log(current.request);
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request, '039c516237b1300054b6a3549dbe5dfc', 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);
gs.log("hi");
// update/add values to variables on item
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.addQuery('request', current.request);
grReqItem.addQuery('cat_item','039c516237b1300054b6a3549dbe5dfc');
grReqItem.query();
if(grReqItem.next()) {
grReqItem.variables.u_test = 'true';
grReqItem.parent = current.sys_id;
grReqItem.update();
}
}
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 07:36 AM
I finally found the problem...This script should be written in after business rule on sc_request. I was writing it on sc_req_item thats why it was not working.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 07:36 AM
I finally found the problem...This script should be written in after business rule on sc_request. I was writing it on sc_req_item thats why it was not working.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2016 04:17 AM
Hi Mansi
I think I can use some of your solution above. But not quite.
Could you please take at look at this: Add item to an existing request
..and see if there you have more hints for it.
Thanks in advance
Soren
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2018 10:00 PM
Can you please advice how to use this in Requested Item workflow? Based on user selections, I need to add certain items to the Request and this looks promising. Thanks!

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