The CreatorCon Call for Content is officially open! Get started here.

Duplicate request/ritm created when using cart in Transform script

phoang
Kilo Expert

I'm trying to create request/requested item from an excel file and using a transform map to do this.   I have an onBefore transform script with the cart info to add that item, however it creates duplicate records.   I've tried with changing the Target table to sc_request and sc_req_item, but no luck.   How can I avoid duplicates?

Here's my onBefore transform script:

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

  var cart = new Cart();

  var item = cart.addItem('XXXXXX');//sysid of item

  cart.setVariable(item,'uniqname_off', source.u_campus_id);

  cart.setVariable(item, 'mgr_uniqname', source.u_campus_id__i_);

  cart.setVariable(item, 'dept_id', source.u_dept_id);

  cart.setVariable(item, 'dept_name', source.u_descr);

  var rc = cart.placeOrder();

})(source, map, log, target);

1 ACCEPTED SOLUTION

phoang
Kilo Expert

Ok I figured it out, I needed a ignore = true; at the end of the script.



Thanks!


View solution in original post

3 REPLIES 3

Manoj Kumar16
Giga Guru

I have never used transform script for adding items to cart.. However you can use:



var cartId= GlideGuid.generate(null);


var cart = new Cart(cartId);



insead of :


var cart = new Cart();



in the transform script.


I tried using what you suggested, and it's still creating a second requested item.   Should the target table still be Requested Item?


phoang
Kilo Expert

Ok I figured it out, I needed a ignore = true; at the end of the script.



Thanks!