create incident and request from the same catalog form

PK14
Kilo Guru

Hi Team,

We have a requirement to streamline the process of ticket creation. The business would like to avoid maintaining multiple forms and instead use a single catalog item/form. Based on the selected "Type of Issue", the system should automatically determine whether to create an Incident or a Request.

For example:
If the issue type is Network & Connectivity, then an Incident should be created.
If the issue type is Administration Documentation, then a Request should be created.

Kindly suggest the best approach to implement this, along with the recommended steps for configuring the creation of both Incident and Request from a single form.

Wrote a record producer code but doesn't create a request record.

(function producerScript(current, producer) {
    var issueType = producer.category;
    // -------- INCIDENT CATEGORIES --------
    var incCategories = [
        'Power & Electrical',
        'Hardware & Infrastructure',
        'Network & Connectivity',
        'Storage & Compute',
        'Monitoring, Telemetry & DCIM',
        'Facilities & Physical Environment',
        'Colocation / Vendor Issues',
        'Change & Human Error',
        'General / Miscellaneous'
    ];
    if (incCategories.indexOf(issueType) > -1) {
        var inc = new GlideRecord('incident');
        inc.initialize();
        inc.short_description = producer.short_description || issueType;
        inc.description = producer.description || "";
        inc.caller_id = gs.getUserID();
        inc.insert();
        action.setRedirectURL(inc);
        gs.addInfoMessage("Incident created for category: " + issueType);
        return;
    }

   
    // -------- REQUEST CATEGORIES --------
    var reqCategories = [
        'Power & Environmental',
        'Infrastructure & Buildouts',
        'Connectivity & Circuits',
        'Asset & Lifecycle Management'
    ];
    if (reqCategories.indexOf(issueType) > -1) {
 
        var reqGr = new GlideRecord('sc_request');
        reqGr.initialize();
        reqGr.requested_for = gs.getUserID();
        reqGr.short_description = producer.short_description || issueType;
        var reqSysId = reqGr.insert();
       
        var ritm = new GlideRecord('sc_req_item');
        ritm.initialize();
        ritm.request = reqSysId;
        ritm.short_description = producer.short_description || issueType;
        ritm.description = producer.description || "";
        var ritmSysId = ritm.insert();
        action.setRedirectURL(ritm);
        gs.addInfoMessage("Request created for category: " + issueType);
        return;
    }
})(current, producer);



5 REPLIES 5

Rafael Batistot
Kilo Patron

Hi @PK14 

 

Instead of forcing sc_request records manually, use the Record Producer itself as the entry point:

 

  1. Keep a single Record Producer with your Type of Issue choice field.
  2. In the Producer Script:
    • If Incident → create directly in the Incident table (what you already did, this is fine).
    • If Request → instead of trying to manually build sc_request, redirect to a Catalog Item that will naturally create the Request / RITM.

This way, you leverage the OOB request creation engine.

Ankur Bawiskar
Tera Patron
Tera Patron

@PK14 

I will still suggest your customer to use separate forms for INC and REQ.

REQUEST -> Is when someone wants to get some request fulfilled example: raising a new laptop and is part of Service Catalog and is usually done by submitting a catalog item

INC -> Is when someone wants to inform something is broken and is part of Incident management and is usually done via record producer from portal or by an agent from workspace/native.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@PK14 

If you want REQ, RITM to be created then please use CARTJS API and don't use GlideRecord on those tables

Sample like this

try{
	var cart = new sn_sc.CartJS();
	var item =
		{
			'sysparm_id': '0336c34407d0d010540bf2508c1ed096',
			'sysparm_quantity': '1',
			'variables':{
				'user': '7282abf03710200044e0bfc8bcbe5d03',
				'asset': '00a96c0d3790200044e0bfc8bcbe5dc3',
				'multiple_choice': 'Phoenix',
			}};
	var cartDetails = cart.addToCart(item);
	var checkoutInfo = cart.checkoutCart();
	gs.info('Order details' + JSON.stringify(checkoutInfo));
}
catch(ex){
	gs.info('Exception'+ex);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@PK14 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader