
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 03:05 PM - edited 06-18-2024 03:06 PM
I have a script includes that works correctly when calling via a catalog item, however, I'm trying to call the same script include via notification script and it does not appear to be passing the parameter, what am I doing wrong.
Script Includes:
var NotaryInstructions = Class.create();
NotaryInstructions.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getNotification: function() {
var sysIDType = this.getParameter('sysparm_query_sysIDType');
var parameters = sysIDType.split(',');
var sysID = parameters[0]; //used to look up records, excluded from this script for brevity
var n_type = parameters[1]; //used to set content
var html = '';
if(n_type == 'instructions'){
html = '<p>This is the instructions</p>';
} else {
html = '<p>This is the other return value</p>';
}
return html;
},
type: 'NotaryInstructions'
});
Notification Script:
NOTE: I also tried using GlideAjax but the log showed that GlideAjax was not recognized as a function from the Notification Script.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var state = current.u_state;
var parameters = current.sys_id + ',instructions';
var helper = new NotaryInstructions();
var instructions = helper.getInstructions(parameters);
email.setSubject("Notary Commission Instructions for the state of " + state.toUpperCase());
//email.setBody(instructions);
template.print(instructions);
})(current, template, email, email_action, event);
Notification Outputs
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2024 02:04 PM - edited 06-24-2024 02:08 PM
We were able to get Developer Support from SNOW and it was the Script includes that needed modified to add an if statement if undefined:
var NotaryInstructions = Class.create();
NotaryInstructions.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getNotification: function(sysIDType) {
if (typeof sysIDType === 'undefined') {
sysIDType = this.getParameter('sysparm_query_sysIDType');
}
var sysID = parameters[0]; //used to look up records, excluded from this script for brevity
var n_type = parameters[1]; //used to set content
var html = '';
if(n_type == 'instructions'){
html = '<p>This is the instructions</p>';
} else {
html = '<p>This is the other return value</p>';
}
return html;
},
type: 'NotaryInstructions'
});
Also a couple of minor edits on the notification script:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
//Get state
var state = current.u_state;
var sysIDType = current.sys_id + ',instructions';
var helper = new NotaryInstructions();
var instructions = helper.getNotification(sysIDType);
email.setSubject("Notary Commission Instructions for the state of " + state.toUpperCase());
email.setBody(instructions);
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 04:17 PM
Hi @litchick10 ,
The issue, most likely, is that your Script Include is client callable; of which should be unchecked if you would like to call the Script Include on a server side mail script.
To test this this out, create a new Script Include with "client callable" unchecked. Then define a function that returns a test string. Call the new Script Include in the mail script,
If everything is working fine, then it's a issue with Script Include being callable.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 09:25 PM
Hi @litchick10
I could see you are not calling the right function in your Script Include. Your Script Include function is getNotification() and you are calling getInstructions(). Refer below updated Script Include and Email Script and give it a try :
var NotaryInstructions = Class.create();
NotaryInstructions.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getNotification: function(sysIDType) {
var parameters = sysIDType.split(',');
var sysID = parameters[0]; //used to look up records, excluded from this script for brevity
var n_type = parameters[1]; //used to set content
var html = '';
if(n_type == 'instructions'){
html = '<p>This is the instructions</p>';
} else {
html = '<p>This is the other return value</p>';
}
return html;
},
type: 'NotaryInstructions'
});
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var state = current.u_state;
var sysIDType = current.sys_id + ',instructions';
var helper = new NotaryInstructions();
var instructions = helper.getNotification(sysIDType);
email.setSubject("Notary Commission Instructions for the state of " + state.toUpperCase());
email.setBody(instructions);
//template.print(instructions);
})(current, template, email, email_action, event);
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 09:11 AM - edited 06-20-2024 09:21 AM
I'm still getting undefined. I tried checking/unchecking the client callable on the script includes. So we don't have any confusion, here is my current script includes:
Here is my updated Notification script:
Here is my Notification preview:
I added a log to the script include and both client callable and non-client callable returned this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 11:40 AM
Since your script include has client callable elements (i.e. this.getParameter('')), I would recommend leaving the client callable checked.
Line 10 of your notification script is passing a value to the function getNotification(), but no arguments are defined.
If you are planning on using the script include for both client side and server side, you'll need to do something like the following:
getNotification: function(sysIDType_str) {
var sysIDType = this.getParameter('sysparm_query_sysIDType')? this.getParameter('sysparm_query_sysIDType') : sysIDType_str;
//....
}
Also I would highly not recommend not toggling the client callable check box for an already established Script Include. I have instances where Script includes were not recognized as client callable, though the checkbox was ticked. I chalked it up to a ServiceNow quirk I had to get used to.
Hope this helps.