Script to create RITM in the workflow

2022_ServiceNow
Tera Expert

Hi,

 

Can anybody please help me with the script to create the RITM based on the state of the previous closed RITM's in the same workflow.

 

Thanks in advance!

1 REPLY 1

Anurag Tripathi
Mega Patron
Mega Patron

This is the script used to generate a REQ-RITM the way any user would./ This way you create a cart, add a catalog item,. add values to the variables and submit, it will generate a REQ (that is in the info here) and using that you can find the RITM too

	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('970949824f69f70099f1b3728110c7d6', 1);

	//fill in the variables on the request item form
	cart.setVariable(item, "test_box", "testing box"); //parameter 2 is variable name & parameter 3 is value
	cart.setVariable(item, "copy_of_test_box", "true");//parameter 2 is variable name & parameter 3 is value
	var rc = cart.placeOrder();
	gs.info(rc.number); //REQ number
-Anurag