<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Overriding SNC Function in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/overriding-snc-function/m-p/1642878#M299804</link>
    <description>&lt;P&gt;Hello All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking to edit the Incident Script Include that calls the IncidentSNC script include. I would like to edit the reopen function in the IncidentSNC script include. I want to clear the assigned to user of the reopened incident. I know that I need to custom the function in the Incident script include. I am looking for examples how to accomplish this. Below are the script includes. Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;// Incident Script Include

var Incident = Class.create();
Incident.prototype = Object.extendsObject(IncidentSNC, {

	initialize: function(incidentGr) {
		IncidentSNC.prototype.initialize.call(this, incidentGr);
	},
	
    type: 'Incident'
});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;// IncidentSNC Script Include

var IncidentSNC = Class.create();

IncidentSNC.prototype = {
	initialize: function(incidentGr) {
		this._gr = incidentGr;
	},
	
	_getGr: function() {
		return this._gr;
	},
	
	hasReopened: function() {
		var incidentGr = this._getGr();
		return (incidentGr.incident_state.changesFrom(IncidentState.RESOLVED) || 
				incidentGr.incident_state.changesFrom(IncidentState.CLOSED) || 
				incidentGr.incident_state.changesFrom(IncidentStateSNC.CANCELED)) &amp;amp;&amp;amp; 
			incidentGr.incident_state != IncidentState.RESOLVED &amp;amp;&amp;amp; 
			incidentGr.incident_state != IncidentState.CLOSED &amp;amp;&amp;amp; 
			incidentGr.incident_state != IncidentState.CANCELED;
	},
	
	reopen: function(gr, email) {
		if (!gr)
			return null;
		
		if (gr.state == IncidentState.RESOLVED) {
			// If the incident is Resolved
			gr.state = IncidentState.IN_PROGRESS;
			gr.incident_state = IncidentState.IN_PROGRESS;
			gr.work_notes = gs.getMessage("The caller did not feel that this issue was resolved");
			gr.update();
			return gr;
		} else if (gr.state == IncidentState.CLOSED) {
			// Create a duplicate incident if this one is Closed
			var duplicateIncId = this.clone(gr.sys_id);
			var gr2 = new GlideRecord("incident");
			gr2.get(duplicateIncId);
			gr2.caller_id = email.from_sys_id;
			gr2.opened_by = email.from_sys_id;
			gr2.contact_type = "email";
			gr2.state = IncidentState.IN_PROGRESS;
			gr2.incident_state = IncidentState.IN_PROGRESS;
			gr2.work_notes = gs.getMessage("The caller did not feel that the incident {0} was resolved", [gr.number+""]);
			gr2.update();
			return gr2;
		}
	},
	
	clone: function(id) {
		var gr = new GlideRecord("incident");
		if (!gr.get(id))
			return null;
		
		var gr2 = new GlideRecord("incident");
		gr2.initialize();
		
		for (var i = 0; i &amp;lt; IncidentSNC.CLONE_FIELDS_ON_REOPEN.length; i++) {
			var field = IncidentSNC.CLONE_FIELDS_ON_REOPEN[i];
			gr2.setValue(field, gr.getValue(field));
		}
		
		return gr2.insert();
	},
	
	type: 'IncidentSNC'
};

IncidentSNC.DEFAULT_CLONE_FIELDS = "additional_assignee_list,assignment_group,business_service,caller_id,category,cmdb_ci,company,description,group_list,impact,knowledge,location,parent,parent_incident,priority,problem_id,rfc,severity,short_description,subcategory,urgency,watch_list";
IncidentSNC.CLONE_FIELDS_ON_REOPEN = gs.getProperty("com.snc.incident.clone_fields_on_reopen", IncidentSNC.DEFAULT_CLONE_FIELDS).split(",");&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 14 Dec 2020 16:55:02 GMT</pubDate>
    <dc:creator>Ben Cervantes</dc:creator>
    <dc:date>2020-12-14T16:55:02Z</dc:date>
    <item>
      <title>Overriding SNC Function</title>
      <link>https://www.servicenow.com/community/developer-forum/overriding-snc-function/m-p/1642878#M299804</link>
      <description>&lt;P&gt;Hello All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking to edit the Incident Script Include that calls the IncidentSNC script include. I would like to edit the reopen function in the IncidentSNC script include. I want to clear the assigned to user of the reopened incident. I know that I need to custom the function in the Incident script include. I am looking for examples how to accomplish this. Below are the script includes. Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;// Incident Script Include

var Incident = Class.create();
Incident.prototype = Object.extendsObject(IncidentSNC, {

	initialize: function(incidentGr) {
		IncidentSNC.prototype.initialize.call(this, incidentGr);
	},
	
    type: 'Incident'
});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;// IncidentSNC Script Include

var IncidentSNC = Class.create();

IncidentSNC.prototype = {
	initialize: function(incidentGr) {
		this._gr = incidentGr;
	},
	
	_getGr: function() {
		return this._gr;
	},
	
	hasReopened: function() {
		var incidentGr = this._getGr();
		return (incidentGr.incident_state.changesFrom(IncidentState.RESOLVED) || 
				incidentGr.incident_state.changesFrom(IncidentState.CLOSED) || 
				incidentGr.incident_state.changesFrom(IncidentStateSNC.CANCELED)) &amp;amp;&amp;amp; 
			incidentGr.incident_state != IncidentState.RESOLVED &amp;amp;&amp;amp; 
			incidentGr.incident_state != IncidentState.CLOSED &amp;amp;&amp;amp; 
			incidentGr.incident_state != IncidentState.CANCELED;
	},
	
	reopen: function(gr, email) {
		if (!gr)
			return null;
		
		if (gr.state == IncidentState.RESOLVED) {
			// If the incident is Resolved
			gr.state = IncidentState.IN_PROGRESS;
			gr.incident_state = IncidentState.IN_PROGRESS;
			gr.work_notes = gs.getMessage("The caller did not feel that this issue was resolved");
			gr.update();
			return gr;
		} else if (gr.state == IncidentState.CLOSED) {
			// Create a duplicate incident if this one is Closed
			var duplicateIncId = this.clone(gr.sys_id);
			var gr2 = new GlideRecord("incident");
			gr2.get(duplicateIncId);
			gr2.caller_id = email.from_sys_id;
			gr2.opened_by = email.from_sys_id;
			gr2.contact_type = "email";
			gr2.state = IncidentState.IN_PROGRESS;
			gr2.incident_state = IncidentState.IN_PROGRESS;
			gr2.work_notes = gs.getMessage("The caller did not feel that the incident {0} was resolved", [gr.number+""]);
			gr2.update();
			return gr2;
		}
	},
	
	clone: function(id) {
		var gr = new GlideRecord("incident");
		if (!gr.get(id))
			return null;
		
		var gr2 = new GlideRecord("incident");
		gr2.initialize();
		
		for (var i = 0; i &amp;lt; IncidentSNC.CLONE_FIELDS_ON_REOPEN.length; i++) {
			var field = IncidentSNC.CLONE_FIELDS_ON_REOPEN[i];
			gr2.setValue(field, gr.getValue(field));
		}
		
		return gr2.insert();
	},
	
	type: 'IncidentSNC'
};

IncidentSNC.DEFAULT_CLONE_FIELDS = "additional_assignee_list,assignment_group,business_service,caller_id,category,cmdb_ci,company,description,group_list,impact,knowledge,location,parent,parent_incident,priority,problem_id,rfc,severity,short_description,subcategory,urgency,watch_list";
IncidentSNC.CLONE_FIELDS_ON_REOPEN = gs.getProperty("com.snc.incident.clone_fields_on_reopen", IncidentSNC.DEFAULT_CLONE_FIELDS).split(",");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Dec 2020 16:55:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/overriding-snc-function/m-p/1642878#M299804</guid>
      <dc:creator>Ben Cervantes</dc:creator>
      <dc:date>2020-12-14T16:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Overriding SNC Function</title>
      <link>https://www.servicenow.com/community/developer-forum/overriding-snc-function/m-p/1642879#M299805</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Here is the official documentation on how to edit those, if you need to:&amp;nbsp;&lt;A href="https://docs.servicenow.com/bundle/paris-it-service-management/page/product/it-service-management/reference/customize-script-includes-itsm.html"&gt;https://docs.servicenow.com/bundle/paris-it-service-management/page/product/it-service-management/reference/customize-script-includes-itsm.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Please mark reply as Helpful/Correct, if applicable. Thanks!&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 17:02:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/overriding-snc-function/m-p/1642879#M299805</guid>
      <dc:creator>Allen Andreas</dc:creator>
      <dc:date>2020-12-14T17:02:28Z</dc:date>
    </item>
  </channel>
</rss>

