Case to Incident Question

Andrew112
Kilo Guru

Just a simple question really.. we have a call table, and there is an option to create an incident from the call. We have a business rule that creates the incident and puts the number in one of the fields of the call.  I believe the code is in this business rule:

 

 

//Creates a new record from a Call, populating it with info from the Call record 

var ctype = current.call_type;

if (ctype != 'hang_up' && ctype != 'wrong_number' && ctype != 'status_call' && ctype != 'general_inquiry' && ctype != 'sc_request') {
	var gr = new GlideRecord(ctype);
	gr.short_description = current.short_description;
	gr.description = current.description.getHTMLValue();
	gr.contact_type = current.contact_type;
	gr.company = current.company;
	gr.opened_by = current.opened_by;
	
	// update task work notes
	var callerName = current.caller.name;
	var taskType = current.call_type.getDisplayValue();
	var currentLink = "[code]<a href='" + current.getLink() + "'>" + current.number + "</a>[/code]";
	var journalEntry = gs.getMessage("This {0} was raised on behalf of {1} from {2}", [taskType, callerName, currentLink]);
	gr.work_notes = journalEntry;

	if (GlidePluginManager.isRegistered('com.glide.domain'))
		gr.sys_domain = getDomain();

	if (ctype == 'incident'){
		gr.caller_id = current.caller;
		gr.location = current.caller.location;
		gr.assignment_group = '985200584fe8d700955e90918110c7de'; //Assign to Service Desk
		gr.comments = current.description.getHTMLValue();
	}

	if (ctype == 'problem')
		gr.opened_by = current.caller;

	if (ctype == 'change_request')
		gr.requested_by = current.caller;

	var sysID = gr.insert();
	current.transferred_to = sysID;
	var url = ctype + '.do?sys_id=' + sysID;
	gs.addInfoMessage(gs.getMessage("{0} transferred to: <a href='{1}'>{2}</a>", [current.number, url, current.transferred_to.getDisplayValue()]));
}

function getDomain(){
	// only set the domain if the caller has a domain that is not global
	if (JSUtil.notNil(current.caller) && JSUtil.notNil(current.caller.sys_domain) && current.caller.sys_domain.getDisplayValue() != 'global')
		return current.caller.sys_domain;
	else
		return getDefaultDomain();
}

 

 

 The part that puts the incident number in the field is here:

 

 

var sysID = gr.insert();
	current.transferred_to = sysID;
	var url = ctype + '.do?sys_id=' + sysID;
	gs.addInfoMessage(gs.getMessage("{0} transferred to: <a href='{1}'>{2}</a>", [current.number, url, current.transferred_to.getDisplayValue()]));
}

 

 

Anyway, although the incident is being created, the incident number is not appearing on the "transferred_to" field on the call which is causing a problem.

 

Screenshot 2024-05-23 at 0.35.58.png

Any help appreciated!

3 REPLIES 3

Tony Chatfield1
Kilo Patron

Hi, is this a before or after BR?
If an afterBR, you would need to update the current record after populating the incident sys_id into transferred to

current.transferred_to = sysID;
current.update();

But only if it is an afterBR



 

It is a before... 

Curious indeed, unfortunately I can't seem to find the 'caller' plugin to test on a PDI.
Does the addInfoMessage() return a valid sys_id and link?
Have you checked list view or xml of impacted record to see if the value is there and that it is not cleared from the form?
Or perhaps ACL, script or policy is preventing population of the field on insert, or another BR, flow or workflow could be clearing the content?

Is this an OOB script or customization? and is your instance domain separated?
I did wonder if setting the domain of the incident via a script, but not necessarily matching the domain of the current record to it, could result in a domain mismatch that impacted visibility of the incident.