
- 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 06:51 AM
Does your table has priority choice values defined?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 06:56 AM
Yes, it does.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 07:02 AM
In email, pass Priority: 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 07:43 AM
Here's my new script with some debugging statements:
s.include('validators');
if (current.getTableName() == "my_custom_task_table") {
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;
gs.warn("email.body.priority = "+email.body.priority);
if (isNumeric(email.body.priority))
gs.warn("in isNumeric conditional");
gs.warn("isNumeric passed");
// if (email.body.priority != undefined && isNumeric(email.body.priority))
// current.priority = email.body.priority;
}
current.update();
}
In the System Log, I get:
Information | Skipping 'Update Ad Hoc Request', did not create or update my_custom_task_table |
Warning | org.mozilla.javascript.EcmaError: "isNumeric" is not defined. |
Caused by error in Inbound Email Actions: 'Update Ad Hoc Request' at line 12 | |
9: | |
10: gs.warn("email.body.priority = "+email.body.priority); | |
11: | |
==> 12: if (isNumeric(email.body.priority)) | |
13: gs.warn("in isNumeric conditional"); | |
14: | |
15: gs.warn("isNumeric passed"); | |
Information | Skipping 'Update Change task', email is a reply, and the record it matches is not in the Inbound Email Action's table |
Warning | org.mozilla.javascript.EcmaError: "isNumeric" is not defined. |
Caused by error in <refname> at line -1 | |
Warning | email.body.priority = 4 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2016 08:06 AM
Hi Nia,
I'm sorry I didn't ask you this yesterday, I'm not sure why this didn't trigger.
Can you change your isNumeric to isNaN? NaN means NotaNumber.