How to raise a catalog request via inbout action

Suvarna4
Tera Contributor

Hi All,

Could any one guide how to raise a catalog request via inbound email action,  the request should create a ritm and task

9 REPLIES 9

@Suvarna4 Can you go through the below API

https://developer.servicenow.com/dev.do#!/reference/api/utah/server/sn_impex/GlideExcelParserScopedA...

 

Thanks & Regards | Chiranjeevi Chaitanya Naram
Kindly mark the answer Correct and Helpful if it helps to resolve your issue.

Robbie
Kilo Patron
Kilo Patron

Hi @Suvarna4,

 

I'd recommend leveraging the Cart API saving the hassle of manually building the REQ, RITM, and running the workflow. 

 

Here's a framework of a script to use in the inbound action (You'll have to update a few variables and id's accordingly for your use case)

 

To help others, please mark as correct and/or helpful.

 

Thanks, Robbie

createRequest();
function createRequest() {
var cart = new Cart();
// add in cart, substitute your catalog item sys_id
var item = cart.addItem('00000000000000000000000000000000');
// set requested for, substitute your requested for
//Set Variables in your Cart Item - item, variable_nmae, parameter
cart.setVariable(item, 'requested_for', '00000000000000000000000000000000');
cart.setVariable(item, 'request_short_description', email.subject.toString());
cart.setVariable(item, 'request_description', email.body_html);
cart.setVariable(item, 'request_type', 'others');
var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
cart.setVariable(item,'comments',cartmsg);
var rc = cart.placeOrder();
}

Ankur Bawiskar
Tera Patron
Tera Patron

@Suvarna4 

you can use Cart API or CartJS Api for this

What did you start with and where are you stuck?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Robbie
Kilo Patron
Kilo Patron

Hi @Suvarna4,

 

Did you see my response below?

 

So as to help others (or for me to help you direct one to one), please mark my response as correct and/or helpful.

 

Earlier response:

I'd recommend leveraging the Cart API saving the hassle of manually building the REQ, RITM, and running the workflow. 

 

Here's a framework of a script to use in the inbound action (You'll have to update a few variables and id's accordingly for your use case)

 

To help others, please mark as correct and/or helpful.

 

Thanks, Robbie

createRequest();
function createRequest() {
var cart = new Cart();
// add in cart, substitute your catalog item sys_id
var item = cart.addItem('00000000000000000000000000000000');
// set requested for, substitute your requested for
//Set Variables in your Cart Item - item, variable_nmae, parameter
cart.setVariable(item, 'requested_for', '00000000000000000000000000000000');
cart.setVariable(item, 'request_short_description', email.subject.toString());
cart.setVariable(item, 'request_description', email.body_html);
cart.setVariable(item, 'request_type', 'others');
var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
cart.setVariable(item,'comments',cartmsg);
var rc = cart.placeOrder();
}

 

Robbie
Kilo Patron
Kilo Patron

Hi @Suvarna4,

 

Did you see my response below?

 

So as to help others (or for me to help you direct one to one), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Earlier response:

I'd recommend leveraging the Cart API saving the hassle of manually building the REQ, RITM, and running the workflow. 

 

Here's a framework of a script to use in the inbound action (You'll have to update a few variables and id's accordingly for your use case)

 

To help others, please mark as correct and/or helpful.

 

Thanks, Robbie

createRequest();
function createRequest() {
var cart = new Cart();
// add in cart, substitute your catalog item sys_id
var item = cart.addItem('00000000000000000000000000000000');
// set requested for, substitute your requested for
//Set Variables in your Cart Item - item, variable_nmae, parameter
cart.setVariable(item, 'requested_for', '00000000000000000000000000000000');
cart.setVariable(item, 'request_short_description', email.subject.toString());
cart.setVariable(item, 'request_description', email.body_html);
cart.setVariable(item, 'request_type', 'others');
var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
cart.setVariable(item,'comments',cartmsg);
var rc = cart.placeOrder();
}