How to generate a RITM from a record producer

mdjoseph12
Giga Contributor

Knowing that ServiceNow advices using a catalog item as opposed to a record producer to generate a RITM, we have a requirement to have agents submit a RITM on behalf of a caller. To achieve this from the user interface, I wanted to generate a ritm from a record producer. Is this possible? If so, how could I trigger the workflow once the ritm is created? 

1 ACCEPTED SOLUTION

Dubz
Mega Sage

Why can't your users just request the catalog item through the service catalog as normal?

If you want to use a record producer i suppose you could use one to create a request record and then use some of the fields on the record producer to populate the request item variables. The script below can be used to create request items and relate them to a parent request.

var itemGr = new GlideRecord("sc_req_item");
itemGr.initialize();
itemGr.cat_item = 'sys_id of catalog item';
itemGr.request = 'sys_id of parent request';
itemGr.state = 1;
var reqItem = itemGr.insert();

var optionGr = new GlideRecord('sc_item_option');
optionGr.initialize();
optionGr.item_option_new = 'sys_id of catalog item variable';
optionGr.value = 'variable value';
var itemID = optionGr.insert();

var relGr = new GlideRecord('sc_item_option_mtom');
relGr.initialize();
relGr.request_item = reqItem;
relGr.sc_item_option = itemID;
relGr.insert();

var startWF = new GlideRecord('sc_req_item');
if(startWF.get(reqItem)){
	startWF.setForceUpdate(true);
	startWF.update();
}

View solution in original post

6 REPLIES 6

Dubz
Mega Sage

Why can't your users just request the catalog item through the service catalog as normal?

If you want to use a record producer i suppose you could use one to create a request record and then use some of the fields on the record producer to populate the request item variables. The script below can be used to create request items and relate them to a parent request.

var itemGr = new GlideRecord("sc_req_item");
itemGr.initialize();
itemGr.cat_item = 'sys_id of catalog item';
itemGr.request = 'sys_id of parent request';
itemGr.state = 1;
var reqItem = itemGr.insert();

var optionGr = new GlideRecord('sc_item_option');
optionGr.initialize();
optionGr.item_option_new = 'sys_id of catalog item variable';
optionGr.value = 'variable value';
var itemID = optionGr.insert();

var relGr = new GlideRecord('sc_item_option_mtom');
relGr.initialize();
relGr.request_item = reqItem;
relGr.sc_item_option = itemID;
relGr.insert();

var startWF = new GlideRecord('sc_req_item');
if(startWF.get(reqItem)){
	startWF.setForceUpdate(true);
	startWF.update();
}

mdjoseph12
Giga Contributor

What would the sys id of the request item be if it hasnt been generated yet? 

itemGr.request = 'sys_id of parent request';

You'd have to run this in an after insert business rule, then you could get the sys_id of the record you've just created.

mdjoseph12
Giga Contributor

ok that makes sense. So my record producer would create records in the sc_req_item table, then an on after insert business rule would relate them to a parent request? How would I delineate between ritms produced from the catalog item on the portal vs ritms created from the record producer for the business rule?