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

Kalaiarasan Pus
Giga Sage

Does your table has priority choice values defined?


Yes, it does.


In email, pass Priority: 4


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


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.