
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2016 08:15 AM
I tried creating a new Inbound Action for a custom task type that we have and the script seems to be giving some errors.
The script is as follows. It is the same as the "Update Incident", "Update Problem", etc. scripts that came with ServiceNow originally:
gs.include('validators');
if (current.getTableName() == "my_custom_task_table_name") {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
if (gs.hasRole("itil")) {
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
if (email.body.priority != undefined && isNumeric(email.body.priority))
current.priority = email.body.priority;
}
current.update();
}
Except I am seeing errors in the logs that say:
org.mozilla.javascript.EcmaError: "isNumeric" is not defined.
Caused by error in <refname> at line 1
==> 1: gs.include('validators');
2:
3: if (current.getTableName() == "my_custom_task_table_name") {
4: current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
AND
org.mozilla.javascript.EcmaError: "isNumeric" is not defined.
Caused by error in Inbound Email Actions: 'Update Ad Hoc Request' at line 14
11: gs.warn("current.assigned_to = "+current.assigned_to, "Inbound debug") ;
12: }
13:
==> 14: if (email.body.priority != undefined && isNumeric(email.body.priority)) {
15: current.priority = email.body.priority;
16: gs.warn("current.priority = "+current.priority, "Inbound debug") ;
17: }
Where am I going wrong? Why does the same script work just fine for Incident but not for my custom task type?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 08:58 AM
My apologies to all who have been so helpful and patient... I'm not sure how to add a comment so that you're all notified but I just figured out the problem. I completely forgot about the Application scope and am working in a different Application scope than Global.
validator script includes is only present in the Global application scope.
If I copy the validator script in my application scope and include the copy that I made, everything works as expected.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 08:18 AM
isNan works. I'm baffled as to why isNumeric will not work in my case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 08:22 AM
Hi Nia,
You can try removing the line gs.include('validators') and add this function in your script.
function isNumeric(text) {
if (text == null)
return true;
var validChars = "0123456789.,-";
return containsOnlyChars(validChars, text);
}
Hope it's helpful.
Thanks and Regards,
Vikas Malhotra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 08:45 AM
Thank you for the suggestion, Vikas but this doesn't explain why isNumeric is failing in my case.
For now, I have removed the entire conditional and my script only has the following lines which seems to work well:
if (current.getTableName() == "my_custom_task_table") {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
}
But I'd love to eventually figure out why isNumeric is failing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 08:52 AM
Hi Nia,
Actually I could help you more on this if I would have able to reproduce this issue. But still, you can check one thing if the script include of name 'validators' is present or not.
I doubt this because isNumeric() function is written in the validators script include but since for some reason it is not able to load the script include, it is not even able to find the function also.
So, you can check if this script include is missing.
Hope it's helpful.
Thanks and Regards,
Vikas Malhotra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 08:55 AM
HI Vikas,
Yes, as noted above, script include validators is available and active in the system. I checked the script and the isNumeric function is defined just as you have pasted it.
I will try and reproduce this issue with another table, perhaps.