- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2019 04:24 AM
When an Escalation is created for an existing case record there are 2 OOB entries created into the case work notes.
I want to change the content of those notes but I can't find the script definition. I have looked into Task, case and escalation tables.
Anyone can point me to the right place?
Below a sample of the OOB notes (erased case and user details form data compliance)
Solved! Go to Solution.
- Labels:
-
Customer Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2019 10:06 AM
This is all driven in the script include called Escalation UTILS. ServiceNow Makes this read only by default, so you may want to contact servicenow to see if you can edit or Insert and Stay and make a clone that you will tie into your instance. Let me know if you have any more questions.
Thanks,
Brian McMinn
Veterans ETS Consulting
Mobile: 530-487-3279
var EscalationUtils = Class.create();
EscalationUtils.prototype = {
initialize: function() {
},
canRequestEscalation: function(gr) {
var gr_esc = new GlideRecord('sn_customerservice_escalation');
gr_esc.addQuery('source_table', gr.sys_class_name);
gr_esc.addQuery('source_record', gr.sys_id);
gr_esc.addQuery('active', true);
gr_esc.query();
if(!gr_esc.next())
return true;
return false;
},
canRequestDeescalation: function(gr) {
var gr_esc = new GlideRecord('sn_customerservice_escalation');
gr_esc.addQuery('source_table', gr.sys_class_name);
gr_esc.addQuery('source_record', gr.sys_id);
gr_esc.addQuery('state', 101); // escalated
gr_esc.addQuery('active', true);
gr_esc.query();
if (gr_esc.next())
return true;
return false;
},
appendNote: function(escalation, fieldName, newValue, oldValue) {
var gr_source = new GlideRecord(escalation.getValue('source_table'));
gr_source.get(escalation.getValue('source_record'));
if(!gr_source) return;
if(fieldName == "state") {
if(escalation.state == 100) { // Requested
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage('{0} has requested to escalate this {1}. {2} created.', [gs.getUserDisplayName(), gr_source.getClassDisplayValue(), escalation.getDisplayValue('number')]);
gr_source.update();
}
// create depend on type
if(escalation.getValue('source_table') == 'sn_customerservice_case' || escalation.getValue('source_table') == 'csm_order_case') {
escalation.work_notes = gs.getMessage('Case: {0}\nCase Short Description: {1}\nAccount: {2}\nContact: {3}\nEscalation Phase: {4}', [gr_source.getDisplayValue('number'), gr_source.getDisplayValue('short_description'), gr_source.getDisplayValue('account'), gr_source.getDisplayValue('contact'), escalation.getDisplayValue('escalation_severity')]);
escalation.update();
}
} else if(escalation.state == 101) { // Escalated
if(!oldValue) {
// skip approval
if(escalation.getValue('source_table') == 'sn_customerservice_case' || escalation.getValue('source_table') == 'csm_order_case') {
escalation.work_notes = gs.getMessage('Case: {0}\nCase Short Description: {1}\nAccount: {2}\nContact: {3}\nEscalation Phase: {4}', [gr_source.getDisplayValue('number'), gr_source.getDisplayValue('short_description'), gr_source.getDisplayValue('account'), gr_source.getDisplayValue('contact'), escalation.getDisplayValue('escalation_severity')]);
escalation.update();
}
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage("Escalation {0} has been approved.", [escalation.getDisplayValue('number')]);
}
} else {
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage("{0} has approved escalation {1}.", [escalation.getDisplayValue('approved_by'), escalation.getDisplayValue('number')]);
}
}
gr_source.update();
} else if(escalation.state == 102) { // Declined
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage("{0} has declined escalation {1}.", [escalation.getDisplayValue('declined_by'), escalation.getDisplayValue('number')]);
gr_source.update();
}
var declineComments = this.getComments(escalation);
if(declineComments != "") {
escalation.work_notes = gs.getMessage("{0}", [declineComments]);
escalation.update();
}
} else if(escalation.state == 103) { // Closed Escalated
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage("Escalation {0} has been closed.", [escalation.getDisplayValue('number')]);
gr_source.update();
}
} else if(escalation.state == 104) { // De-escalation Requested
// TBD
}
} else if(fieldName == "escalation_severity") {
if(gr_source.isValidField('work_notes')) {
gr_source.work_notes = gs.getMessage("Escalation {0} phase has changed: {1} was {2}.", [escalation.getDisplayValue('number'), newValue, oldValue]);
gr_source.update();
}
} else if(fieldName == "trend") {
if(gr_source.isValidField('work_notes')) {
gr_source.work_notes = gs.getMessage("Escalation {0} trend has changed: {1} was {2}.", [escalation.getDisplayValue('number'), newValue, oldValue]);
gr_source.update();
}
} else if(fieldName == "work_notes" || fieldName == "comments") {
if(gr_source.isValidField('work_notes')) {
gr_source.work_notes = gs.getMessage("Escalation {0} has updated:\n{1}", [escalation.getDisplayValue('number'), newValue]);
gr_source.update();
}
}
},
notifyUsers: function(escalation, fieldName) {
if(fieldName == 'state') {
if(escalation.state == 100) { // Requested
gs.eventQueue('sn_customerservice.escalation.request', current, gs.getUserID(), escalation.sys_id);
} else if(escalation.state == 101) { // Escalated
gs.eventQueue('sn_customerservice.escalation.escalated', current, gs.getUserID(), escalation.sys_id);
} else if(escalation.state == 102) { // Declined
gs.eventQueue('sn_customerservice.escalation.declined', current, gs.getUserID(), escalation.sys_id);
} else if(escalation.state == 103) { // Closed
gs.eventQueue('sn_customerservice.escalation.closed', current, gs.getUserID(), escalation.sys_id);
} else if(escalation.state == 104) { // De-escalation Requested
// TBD
}
} else if (fieldName == 'escalation_severity') {
gs.eventQueue('sn_customerservice.escalation.serchange', current, gs.getUserID(), escalation.sys_id);
} else if (fieldName == 'trend') {
gs.eventQueue('sn_customerservice.escalation.trdchange', current, gs.getUserID(), escalation.sys_id);
} else if (fieldName == 'assignment_group') {
gs.eventQueue('sn_customerservice.escalation.gpchange', current, gs.getUserID(), escalation.sys_id);
} else if (fieldName == 'assigned_to') {
gs.eventQueue('sn_customerservice.escalation.aschange', current, gs.getUserID(), escalation.sys_id);
} else if (fieldName == 'comments') {
gs.eventQueue('sn_customerservice.escalation.cmtchange', current, gs.getUserID(), escalation.sys_id);
}
},
getComments: function(gr_escalation) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', gr_escalation.sys_id);
gr.query();
while(gr.next()) {
var approval_state = gr.getValue('state');
if(approval_state == 'approved' || approval_state == 'rejected') {
return gr.comments.getJournalEntry(1);
}
}
return "";
},
getQualifier: function(source_table) {
var query = null;
if(source_table == 'sn_customerservice_case' || source_table == 'csm_order_case') { // case escalation
query = "type=0";
} else if (source_table == 'customer_account') { // account escalation
query = "type=1";
}
return query;
},
type: 'EscalationUtils'
};​

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2019 10:06 AM
This is all driven in the script include called Escalation UTILS. ServiceNow Makes this read only by default, so you may want to contact servicenow to see if you can edit or Insert and Stay and make a clone that you will tie into your instance. Let me know if you have any more questions.
Thanks,
Brian McMinn
Veterans ETS Consulting
Mobile: 530-487-3279
var EscalationUtils = Class.create();
EscalationUtils.prototype = {
initialize: function() {
},
canRequestEscalation: function(gr) {
var gr_esc = new GlideRecord('sn_customerservice_escalation');
gr_esc.addQuery('source_table', gr.sys_class_name);
gr_esc.addQuery('source_record', gr.sys_id);
gr_esc.addQuery('active', true);
gr_esc.query();
if(!gr_esc.next())
return true;
return false;
},
canRequestDeescalation: function(gr) {
var gr_esc = new GlideRecord('sn_customerservice_escalation');
gr_esc.addQuery('source_table', gr.sys_class_name);
gr_esc.addQuery('source_record', gr.sys_id);
gr_esc.addQuery('state', 101); // escalated
gr_esc.addQuery('active', true);
gr_esc.query();
if (gr_esc.next())
return true;
return false;
},
appendNote: function(escalation, fieldName, newValue, oldValue) {
var gr_source = new GlideRecord(escalation.getValue('source_table'));
gr_source.get(escalation.getValue('source_record'));
if(!gr_source) return;
if(fieldName == "state") {
if(escalation.state == 100) { // Requested
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage('{0} has requested to escalate this {1}. {2} created.', [gs.getUserDisplayName(), gr_source.getClassDisplayValue(), escalation.getDisplayValue('number')]);
gr_source.update();
}
// create depend on type
if(escalation.getValue('source_table') == 'sn_customerservice_case' || escalation.getValue('source_table') == 'csm_order_case') {
escalation.work_notes = gs.getMessage('Case: {0}\nCase Short Description: {1}\nAccount: {2}\nContact: {3}\nEscalation Phase: {4}', [gr_source.getDisplayValue('number'), gr_source.getDisplayValue('short_description'), gr_source.getDisplayValue('account'), gr_source.getDisplayValue('contact'), escalation.getDisplayValue('escalation_severity')]);
escalation.update();
}
} else if(escalation.state == 101) { // Escalated
if(!oldValue) {
// skip approval
if(escalation.getValue('source_table') == 'sn_customerservice_case' || escalation.getValue('source_table') == 'csm_order_case') {
escalation.work_notes = gs.getMessage('Case: {0}\nCase Short Description: {1}\nAccount: {2}\nContact: {3}\nEscalation Phase: {4}', [gr_source.getDisplayValue('number'), gr_source.getDisplayValue('short_description'), gr_source.getDisplayValue('account'), gr_source.getDisplayValue('contact'), escalation.getDisplayValue('escalation_severity')]);
escalation.update();
}
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage("Escalation {0} has been approved.", [escalation.getDisplayValue('number')]);
}
} else {
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage("{0} has approved escalation {1}.", [escalation.getDisplayValue('approved_by'), escalation.getDisplayValue('number')]);
}
}
gr_source.update();
} else if(escalation.state == 102) { // Declined
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage("{0} has declined escalation {1}.", [escalation.getDisplayValue('declined_by'), escalation.getDisplayValue('number')]);
gr_source.update();
}
var declineComments = this.getComments(escalation);
if(declineComments != "") {
escalation.work_notes = gs.getMessage("{0}", [declineComments]);
escalation.update();
}
} else if(escalation.state == 103) { // Closed Escalated
if(gr_source.isValidField('work_notes')){
gr_source.work_notes = gs.getMessage("Escalation {0} has been closed.", [escalation.getDisplayValue('number')]);
gr_source.update();
}
} else if(escalation.state == 104) { // De-escalation Requested
// TBD
}
} else if(fieldName == "escalation_severity") {
if(gr_source.isValidField('work_notes')) {
gr_source.work_notes = gs.getMessage("Escalation {0} phase has changed: {1} was {2}.", [escalation.getDisplayValue('number'), newValue, oldValue]);
gr_source.update();
}
} else if(fieldName == "trend") {
if(gr_source.isValidField('work_notes')) {
gr_source.work_notes = gs.getMessage("Escalation {0} trend has changed: {1} was {2}.", [escalation.getDisplayValue('number'), newValue, oldValue]);
gr_source.update();
}
} else if(fieldName == "work_notes" || fieldName == "comments") {
if(gr_source.isValidField('work_notes')) {
gr_source.work_notes = gs.getMessage("Escalation {0} has updated:\n{1}", [escalation.getDisplayValue('number'), newValue]);
gr_source.update();
}
}
},
notifyUsers: function(escalation, fieldName) {
if(fieldName == 'state') {
if(escalation.state == 100) { // Requested
gs.eventQueue('sn_customerservice.escalation.request', current, gs.getUserID(), escalation.sys_id);
} else if(escalation.state == 101) { // Escalated
gs.eventQueue('sn_customerservice.escalation.escalated', current, gs.getUserID(), escalation.sys_id);
} else if(escalation.state == 102) { // Declined
gs.eventQueue('sn_customerservice.escalation.declined', current, gs.getUserID(), escalation.sys_id);
} else if(escalation.state == 103) { // Closed
gs.eventQueue('sn_customerservice.escalation.closed', current, gs.getUserID(), escalation.sys_id);
} else if(escalation.state == 104) { // De-escalation Requested
// TBD
}
} else if (fieldName == 'escalation_severity') {
gs.eventQueue('sn_customerservice.escalation.serchange', current, gs.getUserID(), escalation.sys_id);
} else if (fieldName == 'trend') {
gs.eventQueue('sn_customerservice.escalation.trdchange', current, gs.getUserID(), escalation.sys_id);
} else if (fieldName == 'assignment_group') {
gs.eventQueue('sn_customerservice.escalation.gpchange', current, gs.getUserID(), escalation.sys_id);
} else if (fieldName == 'assigned_to') {
gs.eventQueue('sn_customerservice.escalation.aschange', current, gs.getUserID(), escalation.sys_id);
} else if (fieldName == 'comments') {
gs.eventQueue('sn_customerservice.escalation.cmtchange', current, gs.getUserID(), escalation.sys_id);
}
},
getComments: function(gr_escalation) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', gr_escalation.sys_id);
gr.query();
while(gr.next()) {
var approval_state = gr.getValue('state');
if(approval_state == 'approved' || approval_state == 'rejected') {
return gr.comments.getJournalEntry(1);
}
}
return "";
},
getQualifier: function(source_table) {
var query = null;
if(source_table == 'sn_customerservice_case' || source_table == 'csm_order_case') { // case escalation
query = "type=0";
} else if (source_table == 'customer_account') { // account escalation
query = "type=1";
}
return query;
},
type: 'EscalationUtils'
};​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2019 12:33 AM
Very helpful answer,
I reached out to ServiceNow to see what options they have to achieve what we need.
Thanks!