Creating an Incident from a Case

MStritt
Tera Guru

On our Case table, we have a UI Action called 'Create Incident'. I would like to update the script so it passes the values in the 'Service' field (u_service) and 'Assignment Group field (assignment_group) on the Case to the newly created Incident.

Here's the script currently. How would I add the additional values?

find_real_file.png

 

1 ACCEPTED SOLUTION

 

Use below code to update these custom fields.

 

createIncidentFromCase: function(caseGr, uiActionHandler) {
		var incGr = new GlideRecord("incident");
		var ep = new GlideScriptedExtensionPoint().getExtensions(ServiceManagementIntegrationConstants.CASE_INC_EXTENSION_POINT);
		//If there is any other new extension instance other than the OOB one, concat them together
		//The extension instance with higher order number would overwrite the one with lower order number
		for(var i = 0; i < ep.length; i ++){
			var point = ep[i];
			point.copyFieldsFromCaseToIncident(incGr, caseGr);
		}
		
		var incSysId = incGr.insert();
                var inc = new GlideRecord('incident');
                inc.addQuery('sys_id',incSysId);
                inc.query();
                while(inc.next()){

                  inc.cmdb_ci = current.u_service;
                  inc.assignment_group = current.assignment_group;
                  inc.update();

                }
		caseGr.incident = incSysId;
		caseGr.update();
		gs.addInfoMessage(gs.getMessage("Incident {0} created", incGr.number));
		uiActionHandler.openGlideRecord(incGr);
		uiActionHandler.setReturnURL(caseGr);
	},

 

Regards,

Sachin

View solution in original post

23 REPLIES 23

OK. That didn't work. If I use the new code above, do I need to make any changes to any of my fields? Or just update the script include with this code?

just update script include with latest code.

 

Regards,

Sachin

I think what I might be able to do, is change the Service field on the Case form to a reference field. Then, add a reference qual condition to narrow the search results to the 20 I created. Then, they will only see these 20 choices when searching.

I was able to change the Service field on the Case to a reference field, and have it reference the cmdb_ci table. I added a condition to only show choices that I created. I created an Incident from the Case, and the Configuration Item and Assignment Group fields were populated with the values from the Case.