Submit Catalog Item from Workflow (new Cart() or not)

A_Nelson
Kilo Expert

Hello,

I am trying to kick-off a request item from a different workflow (using sub-workflows are not maintainable/manageable). I tried using the "new Cart()" function and it works for the most part. I would like the RITM to be tied to the current REQ that the current workflow is working on.

I tried adding the last 2 lines but does not work. What would be the best way to do this? 

Thanks,

createRequest();

function createRequest() {

		var cartId = GlideGuid.generate(null);
	
	        workflow.info("^^^^^cartID " + cartId);
		var cart = new Cart(cartId);
		// Add in cart, sys_id for Internal Service Desk Request catalog item
		// This sys_id is for the "Create a New User"
		var item = cart.addItem('4e730823ad443c03c3ebb72244b0122');
		
		// Fill the "Create a New User" form fields on the Current RITM variables
		cart.setVariable(item, 'VS_R10_requested_for', current.variables.VS_R10_requested_for);
		
		cart.setVariable(item, 'nars_center' , workflow.scratchpad.center);
		cart.setVariable(item, 'nars_role' , workflow.scratchpad.role);
		
	
		// Places order and creates request
		var rc = cart.placeOrder();
		    rc.request=current.request;
		    rc.update();
			
}
1 ACCEPTED SOLUTION

Manoj Kumar16
Giga Guru

Hi,

There is an API named GlideAppCalculationHelper(), which you can use to dynamically generate the Requests and Request Items with variables and the workflow gets automatically added. 

Please check the below links to know how can you use the API-

https://community.servicenow.com/community?id=community_question&sys_id=b2a58feddbd8dbc01dcaf3231f96...

 

https://community.servicenow.com/community?id=community_question&sys_id=2f8821dbdb1fb700fff8a345ca96...

View solution in original post

1 REPLY 1

Manoj Kumar16
Giga Guru

Hi,

There is an API named GlideAppCalculationHelper(), which you can use to dynamically generate the Requests and Request Items with variables and the workflow gets automatically added. 

Please check the below links to know how can you use the API-

https://community.servicenow.com/community?id=community_question&sys_id=b2a58feddbd8dbc01dcaf3231f96...

 

https://community.servicenow.com/community?id=community_question&sys_id=2f8821dbdb1fb700fff8a345ca96...