
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2018 04:25 PM
I am getting the below error while calling a cart API.
Cannot find function addItem in object [object CartJS].
TypeError: Cannot find function addItem in object [object CartJS].
Here are my scripts:
Run Script :
OpenRequestedItem();
function OpenRequestedItem()
{
var oldritmid = current.sys_id;
gs.info('runscript oldritmid is:' +oldritmid);
var x = new commonSI(); // calling Script Include
x.openCleanUpRitm1(oldritmid); // calling function
}
Script Include Code:
openCleanUpRitm1:function(oldRitmId)
{/* This is to open a Catalog item at run tim*/
try{
gs.info('script include oldRitmId is:' +oldRitmId);
var cart = new sn_sc.CartJS();
cart.addItem('d3fc15afdb9a8780c536f3f7bf9619a2'); // sys id of the catalog item
cart.setVariable(item,'u_ritm',oldRitmId);
var rc = cart.placeOrder();
return(rc);
}
catch(err)
{
gs.addErrorMessage(err.message);
gs.addErrorMessage(err);
}
}
I am doing all this in a scoped application.
Let me know where i am doing incorrectly.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2018 05:26 PM
Can you have your variables like,
'variables':{
'u_ritm': oldRitmId.toString(),
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2018 05:25 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2018 05:26 PM
Can you have your variables like,
'variables':{
'u_ritm': oldRitmId.toString(),
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2018 05:33 PM
Thanks Srivastava for the immediate help
It worked out.
Thanks a ton!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2019 08:46 PM
Hi Shishir,
Any idea how would the JSON look like for variableSet?