Cart API Help

RunsumS
Tera Contributor

Hi Team,

 

Can some help me with below requirement step by step.

 

I need to submit a catalog item once i receive an email and auto assigned to group service desk level 1 as a default group.

1 ACCEPTED SOLUTION

Runjay Patel
Giga Sage

Hi @RunsumS ,

 

You can do like below.

 

  1. Create one Inbound action and give your identifier to execute the same once receive email to cerate RITM.
  2. Write below script to create RITM and assign to your service desk group.
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('sys_id of your catalog item');
cart.setVariable(item,'put your variable name ','your variable value');
cart.setVariable(item,'put your variable name2 ','your variable value2');

//For example to get the group you can use: email.body.u_group_name where u_group_name is keyword which hold the group in email body.
var group = email.body.u_group_name;
var request= cart.placeOrder();

var grRITM = new GlideRecord("sc_req_item");
if(grRITM.get("request", rc.sys_id+"")) {
grRITM.assignment_group=group ;
grRITM.update();
}

 

You can also refer this link, it has all the details about Cart API: https://servicenowwithrunjay.com/create-ritm-using-cart-api-in-servicenow/

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

View solution in original post

2 REPLIES 2

Runjay Patel
Giga Sage

Hi @RunsumS ,

 

You can do like below.

 

  1. Create one Inbound action and give your identifier to execute the same once receive email to cerate RITM.
  2. Write below script to create RITM and assign to your service desk group.
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('sys_id of your catalog item');
cart.setVariable(item,'put your variable name ','your variable value');
cart.setVariable(item,'put your variable name2 ','your variable value2');

//For example to get the group you can use: email.body.u_group_name where u_group_name is keyword which hold the group in email body.
var group = email.body.u_group_name;
var request= cart.placeOrder();

var grRITM = new GlideRecord("sc_req_item");
if(grRITM.get("request", rc.sys_id+"")) {
grRITM.assignment_group=group ;
grRITM.update();
}

 

You can also refer this link, it has all the details about Cart API: https://servicenowwithrunjay.com/create-ritm-using-cart-api-in-servicenow/

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Thanks @Runjay Patel 

 

It worked. Also i have gone through your blog, it's good!!