Ankur Bawiskar
Tera Patron

Hi Gautam,

can you update code as below; ensure you use proper field on incident table to store the ritm reference

createRITM();

function createRITM() { 

 var ritm = new GlideRecord("sc_req_item");
    ritm.initialize();
    ritm.company = current.company;
    ritm.u_req_for = current.caller_id;
    ritm.u_request_type = current.u_issue_type;
    ritm.assignment_group = current.assignment_group;
    ritm.configuration_item = current.cmdb_ci;
    ritm.short_description = current.short_description;
    ritm.description = current.description;
    ritm.work_notes = current.work_notes;
    ritm.comments = current.comments;
    ritm.state = '1';
    ritm.priority = current.priority;
    ritm.watch_list = current.watch_list.getDisplayValue().toString();
    ritm.parent = current.sys_id;
    ritm.insert();
	
	
	current.active = false;
	current.state = 8; // cancelled state
	current.<incidentField> = ritm.sys_id;
gs.addInfoMessage("Incident has cancelled, Requested Item " + ritm.number + " created.");
		

	action.setRedirectURL(ritm);
    action.setReturnURL(current);
	
	}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

 

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