Calling JavascriptProbe from UI action menu

Ankit Bansal
Kilo Contributor

Hello,

I am very new to ServiceNow and trying to learn/create application using studio.

I have created a table from where using "UI Action" i could able to read data from that new table. now i would like call a ECC queue for this. Written below test code but when i click on UI action menu its return error "org.mozilla.javascript.EcmaError: "Test " is not defined. 

Can we not call Script include by this? 

+++++ Code in UI action +++++
var test = new Test();
test.TestSync();
+++++++++++++++++++

+++++ Code in Script include +++++
var Test =Class.create();
Test.prototype={
initialize :function(){
gs.info("Test");
},
TestSync :function(){
var jspr = new JavascriptProbe('MyMIDServer');
jspr.setName('TestLog');
jspr.setJavascript('ms.log("TestLog");');
jspr.create();
},

type :'Test'};
+++++++++++++++++++

1 ACCEPTED SOLUTION

Okay. Add global. Infort of the script include name Var jspr = new global.javascriptProbe(....)

View solution in original post

17 REPLIES 17

I have put inside ajax script here is the sample code but getting following error. Not sure if its correct or wrong?

org.mozilla.javascript.EcmaError: "JavascriptProbe" is not defined.

===== Server Include ======
var Test = Class.create();
Test.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

 initialize :function(){
 gs.info("Test");
},
TestSync :function(){
 var jspr = new JavascriptProbe('MIDServer');
 jspr.setName('TestLog');
 jspr.addParameter("skip_sensor", true);
 jspr.setJavascript('ms.log("TestLog");');
 jspr.create();
 
},

type :'Test'});
==================

===== UI Action ======
var test = new Test();
test.TestSync();
====================

I have put inside ajax script here is the sample code but getting following error. Not sure if its correct or wrong?

 

org.mozilla.javascript.EcmaError: "JavascriptProbe" is not defined.

 

===== Server Include ======
var Test = Class.create();
Test.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

 

 initialize :function(){
 gs.info("Test");
},
TestSync :function(){
 var jspr = new JavascriptProbe('MIDServer');
 jspr.setName('TestLog');
 jspr.addParameter("skip_sensor", true);
 jspr.setJavascript('ms.log("TestLog");');
 jspr.create();
 
},

 

type :'Test'});
==================

 

===== UI Action ======
var test = new Test();
test.TestSync();
====================

ARG645
Tera Guru

Ankith,

you are coding it right. make sure the UI Action is not a Client side UI Action. 

find_real_file.png

Thank you,

Aman Gurram

Yes, I have unchecked 'Client' option but still same issue.

Is your script include inactive ? Also, is client callable checkbox unchecked in your script include?