How to submit a catalog item from script?

karthikbabu
Giga Expert

Hi All,

 

I am trying to create an automatic ticket every month on 1st. The ticket should be created as a RITM which means it should be created from an existing catalog item (in our case "ADHOC item). it should follow the catalog item workflow. 

Please advise.

 

Thanks,

Karthik 

1 ACCEPTED SOLUTION

The cart API isn't instantiated via a GlideRecord. Also, you're not defining "adhoc" anywhere in your script. 

Try this:

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
 //add your requested item to the cart by sys_id of the catalog item
var item = cart.addItem('4054428fdb151f0097679ec6db9619c0', 1);

//fill in the variables on the request item form
cart.setVariable(item,"u_requested_for", "e80edd6edbec6bc097275e25ca9619a4"); 
cart.setVariable(item,"contact_number", "0");
cart.setVariable(item,"assignment_group", "87ec1c342b2e71406c487fb5a8da1524"); 
cart.setVariable(item,"application_service", "cdedfbcedb0f9744c291c170ba9619a7");
cart.setVariable(item,"short_description", email.subject);
cart.setVariable(item,"description", email.body_text);
var rc = cart.placeOrder();

 

After that, run your script to set your requested for values on sc_request or sc_cat_item (as you did in your example). A side note, you should revisit that GlideRecord. I don't know where you're getting "email.body_text" from (assuming you're running this on a schedule as you mentioned in your original post) and your variables and ritmSysID seem a little out of place, as you're not doing anything with them.

View solution in original post

10 REPLIES 10

I agree with you Sachin. But we are in Jakarta version and flow designer starts from Kingston.