Help Needed in CART API

dheeraaj
Giga Expert

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.

1 ACCEPTED SOLUTION

Can you have your variables like,



'variables':{


'u_ritm': oldRitmId.toString(),


}


View solution in original post

8 REPLIES 8

ctomasi, abhinayb-rad



Can the experts please help me out !


Can you have your variables like,



'variables':{


'u_ritm': oldRitmId.toString(),


}


Thanks Srivastava for the immediate help



It worked out.




Thanks a ton!!!


Hi Shishir,

Any idea how would the JSON look like for variableSet?

Thanks in Advance