Autocreate Incident and Incident task from Case.

sreeshsurendran
Tera Guru

Hi all,

 

My requirement is to create Incident and Incident Task for the below mentioned conditions from the case. So, the case table has a hidden field called 'Issue Type'.

 

  1. If Issue Type is Network --> Create Incident and map the fields.
  2. If Issue Type is Openreach --> Create Incident and Incident task and map the fields.

 

I tried this via BR but not able to the script logic correctly. Any help would be greatly appreciated.

 

Best Regards,

Sreesh Surendran

2 REPLIES 2

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @sreeshsurendran you will need to create a business rule for this, please share the script which you have attempted so far...

 

(function executeRule(current, previous /*null when async*/) {

    if (current.issue_type == 'Network') {
        var incidentGR = new GlideRecord('incident');
        incidentGR.initialize()
        incidentGR.short_description = current.short_description;
        // Set other fields...
        var incidentSysId = incidentGR.insert(); 
    }  else if (current.issue_type == 'Openreach') {
        var incidentGR = new GlideRecord('incident');
        incidentGR.initialize(); 
        incidentGR.short_description = current.short_description; 
        // Set other fields...
        var incidentSysId = incidentGR.insert(); 
        var incidentTaskGR = new GlideRecord('incident_task');
        incidentTaskGR.initialize(); 
        incidentTaskGR.short_description = current.short_description;
        var incidentTaskSysId = incidentTaskGR.insert(); 
    }
})(current, previous);

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi @Sohail Khilji ,

 

I've used a before BR on Insert and Update. Please find below the script I've attempted.

 

(function executeRule(current, previous /*null when async*/) {
	// Add your code here
	if(!current.isActionAborted())
	{
		var incGr = new GlideRecord("incident");
		var CalledFromBR = true;
		if (current.incident.nil())
		{
			var CrInc = new CSMIncidentIntegrations_BT().copyFieldsFromCaseToIncident(incGr,current,CalledFromBR);
			var incSysId = incGr.insert();
			current.incident = incSysId;
		}
	}
	if(current.u_issue_type == 'Openreach')
	{
		var inc = new GlideRecord('incident_task');
		inc.initialize();
		inc.short_description = current.short_description;
		inc.assignment_group = current.assignment_group;
		inc.incident = incGr.sys_id;
	}
}
)(current, previous);