Setting the requested_for and opened_by through cart script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2016 08:44 AM
This is my code for creating the request, but i am having issues inserting the requested_for and opened_by
any help would be great, everything else works perfect.
Thanks,
var catItem = new GlideRecord("sc_cat_item");
catItem.addQuery("name", "=", "Windows Security Group - Add/Remove Members - Automated");
catItem.addQuery("active", true);
catItem.query();
if(catItem.next())
{
var cart = new Cart();
var item = cart.addItem(catItem.sys_id);
cart.setVariable(item, "requested_for", "fdce3911e904300020939befc5e26736");
//cart.setVariable(item, "opened_by", "fdce3911e904300020939befc5e26736");
cart.setVariable(item, "GroupName", JSON.stringify(groupJSON));
cart.setVariable(item, "GroupType", groupScope);
cart.setVariable(item, "GroupOwnerName", approver);
cart.setVariable(item, "ApproverName", approver);
cart.setVariable(item, "RemoveUserOrGroup", JSON.stringify(userJSONRemoven));
cart.setVariable(item, "RemoveAll", membersRemoveAll);
cart.setVariable(item, "BusinessCase", "Test");
//form has different list collector for Universal/Global groups
if(groupScope == "Universal")
{
cart.setVariable(item, "AddUserOrGroupUniversal", JSON.stringify(userJSONAddn));
}
else
{
cart.setVariable(item, "AddUserOrGroupGlobal", JSON.stringify(userJSONAddn));
}
var rc = cart.placeOrder();
updateRITM(rc.sys_id);
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 06:01 AM
Hi Shay,
The definition of initialize function in Cart script include is as below.
initialize: function(cartName, userID) {
this.cartName = !cartName ? null : cartName;
this.userID = !userID ? null : userID;
this.cart = this.getCart();
this.clearCart();
},
How about trying to pass these parameters, while you create a new Cart object.
var cart = new Cart("Default", "fdce3911e904300020939befc5e26736");
Hope that helps.
Mandar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 01:27 AM
Hi Shay ,
Can you try below code it would help for you.
cart.setVariable(item, 'requested_for' , request.requested_for);
cart.setVariable(item, 'opened_by' , request.requested_for);