Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Link an Request to an Incident and have it populate in a related list

AM24
Giga Guru

I have a Incident. I use the Create Request UI action to create a new request. It directs to Service Catalog forms from which I can create a request. What would be the steps to link this request to than incident? How would I get this request linked to that incident so it would show up in an embedded related list?

 

This is the code used for the Create Request UI action so far:

current.update();
var url;
var activeCatalogsCount = sn_sc.Catalog.getCatalogCount();
if (activeCatalogsCount === 1) {
    url = "catalog_home.do?sysparm_view=catalog_default&sysparm_parent_table=" + current.sys_class_name + "&sysparm_parent_sys_id=" + current.sys_id;
}
else {
    url = "catalogs_home.do?sysparm_view=catalogs_default&sysparm_parent_table=" + current.sys_class_name + "&sysparm_parent_sys_id=" + current.sys_id;
}


action.setRedirectURL(url);

This is the embedded related list that the new requests should show up in.

AM24_0-1751407145597.png

 

7 REPLIES 7

WillieW
Tera Expert

I suggest that you look at existing OOB UI Actions that create records in a table. Such as UI Action 'Create Case' defined on the 'sn_customerservice_case' table. Your script above does not create a record.

@AM24 if your catalog item is a record producer then try this

var request = producer.request; // current request

request.incident = request.getParameter('incident'); // Pass via URL

request.update();

Please hit like and Mark Helpful if you liked it
Regards,
Prasanna

Where would I use this code? With the Create Request Action, I get taken to two catalogs from where I have several different requests.

You can try 

1.By adding reference feild on request table with the reference as incident

2.Modify UI action on incident form

var incId = g_form.getUniqueValue();
var url = '/com.glideapp.servicecatalog_cat_item_view.do?sys_id=CATALOG_ITEM_SYS_ID&incident=' + incId;
window.open(url, '_blank');

3. In the catalog item script, after item submission set the request incident field 

var incId = g_form.getUniqueValue();

var url = '/com.glideapp.servicecatalog_cat_item_view.do?sys_id=CATALOG_ITEM_SYS_ID&incident=' + incId;

window.open(url, '_blank');

4. Configure the releated list on incident form

Please hit like and Mark Helpful if you liked it
Regards,
Prasanna