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

The JavaScript Probe is healthy. No need to change it. 

- Not sure why you cant find the logs in agent logs. 

But this is what you can do to see if your probe worked. 

 

Navigate to 

Mid Server -> Servers -> (Click on your Mid Server)-> From related links Click on Grab MID logs -> You should find agent0.log0 of type Output. 

Wait for sometime to receive the Input for agent0.log0. Once you get it, open the attachment that comes with it named something like payload.xml. 

 

Then do a CNTRL+F and search for your log statement. 

Please close this thread if your questins was answered so that it may help others in future. If not, let me know if you have further questions.

tim_broberg
ServiceNow Employee
ServiceNow Employee

You need to call ms.log(String) to print messages in the agent log from mid server javascript.