- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2019 07:25 AM
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?
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2019 07:33 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2019 07:33 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2019 10:35 AM
What would the sys id of the request item be if it hasnt been generated yet?
itemGr.request = 'sys_id of parent request';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2019 02:20 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2019 07:12 AM
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?