Inbound Action: "isNumeric" is not defined

Nia McCash
Mega Sage
Mega Sage

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?

1 ACCEPTED SOLUTION

Nia McCash
Mega Sage
Mega Sage

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.


View solution in original post

21 REPLIES 21

Thanks for the info and for being patient with a new SN admin here....



But if I understand you correctly, then in my copy/pasted example above,   email.body.priority should not be empty as the text Priority: 4 - Low is part of the message.   I'm not understanding why email.body.priority would be undefined.



In fact, my tests reveal the Inbound Action always fails to update the record (ie. I always get the error in the syslog) ONLY when the text Priority: some text here is present.


Did you check whether script include "validators" is active in your instance. I believe script Include "validators" is inactive.


Yes, it's active.   I didn't think to check to thank you for suggesting it.


One last try, can you check if isNumeric() method is defined in the script include "validators".


Yes, it is defined as vikky has defined it below (Re: Inbound Action: "isNumeric" is not defined )