- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 03:12 AM
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'};
+++++++++++++++++++
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2018 10:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 11:20 AM
Huh. I tweaked your stuff slightly and dropped it in a background script and it worked for me.
var Test =Class.create();
Test.prototype={
initialize :function(){
gs.info("Test");
},
TestSync :function(){
var jspr = new JavascriptProbe('snc_rba_mid');
jspr.setName('TestLog');
jspr.setJavascript('ms.log("TestLog");');
jspr.create();
},
type :'Test'};
var test = new Test();
JSUtil.logObject(test);
test.TestSync();
I got an appropriate ecc_queue output from running this.
Are you sure you created your script include as a script include, not a mid server script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 10:34 PM
Thanks tim,
Its working fine with background script menu. but not while I am creating Ui action and Script Include in Studio.
its throwing me below error, tough I have made JSUtil is golabl in its property
JSUtil undefined, maybe missing global qualifier
Regards,
Ankit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 01:15 PM
you cannot call script include from UI action, instead, you should call ajax script and inside ajax script you can call the script include.
It will work perfectly in background script since they are run on server side. However, UI action is client side and it cannot access script includes directly unless called via ajax.
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 02:40 PM
Are you sure?