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

Script to generate req, ritm, task via inbound action servicenow

Sriram28
Tera Contributor

Hello Team

 

Can someone please give me script create req, ritm , task for a particular catalog item via inbound action

 

Thanks,

Sriram

3 REPLIES 3

Mark Manders
Mega Patron

What did you already try and where are you stuck?
What is the email that is being received by the instance?

Why not do it simple and use Flow Designer?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

palanikumar
Giga Sage
Giga Sage

Hi,

Below script will create REQ and RITM. Task will be created only based on flow or workflow attached to the catalog item

var cart = new sn_sc.CartJS();
var requestedFor = '<sys_id of user>';
var variableVal1 = 'value 1';
var variableVal2 = 'value 2';

var requestedItem = {
	'sysparm_id': '<sys_id of catalog item>', 
	'sysparm_quantity': '1', // You can change this if you want to order more quantity
	'variables': {
		'requested_for': requestedFor, 
		'short_description': variableVal1,
		'description': variableVal2
	}
};

var checkoutInfo = cart.checkoutCart();
var cartDetails = cart.orderNow(requestedItem);
var request = cart.submitOrder(request); // This will return the Glide record of REQ record
Thank you,
Palani

Ankur Bawiskar
Tera Patron
Tera Patron

@Sriram28 

your can use Inbound flow low-code, no-code approach and use "Submit Catalog Item Request" flow action to generate REQ, RITM and once that item is submitted it's associated Flow/Workflow will create the catalog task

check this link for help

Easiest way to Trigger Catalog Item Request via Inbound Email 

OR

You can also use inbound action and CartJS API to submit that catalog item

something like this

var cart = new sn_sc.CartJS();
var request1 = {
	'sysparm_id': 'ec10f4fd47266110b81cd855d36d4308', // sys_id of catalog item
	'sysparm_quantity': '1',
	'variables': {
		'requested_for': producer.requested_for, //'8efae6cbdb038b00d6563cae7c961
		'short_description': producer.short_description,
		'description': producer.description
	}
};

var checkoutInfo = cart.checkoutCart();
var cartDetails = cart.orderNow(request);
var requestDetails = cart.submitOrder(request);

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

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