- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 06:58 AM
I am Trying to debug my UI action after trying to follow the template set out in this blog
Client & Server Code in One UI Action - ServiceNow Guru
Both styles of logging do not seem to work in my code. I am not sure if doing this within a scoped application requires more permissions or something else.
Any Ideas ? I do not see any messages at the top of my screen nor messages below the number field
Here is my code:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 09:47 AM
Hi Ian,
Thanks for the update. There was error on how you were displaying info message. Syntax is gs.info. I see you mentioned in your code as gs.Info(Error with Caps I)
Here is the final script :
runBusRuleCode();
//Server-side function
function runBusRuleCode(){
gs.addInfoMessage('IAY Package is ' + current.location_package.getDisplayValue());
try{
// var collectionGr = new GlideRecord('x_enig_extreme_quo_product_collection_location');
var collectionGr = new GlideRecord('incident');
gs.addInfoMessage('INIT gr');
collectionGr.addQuery('collection_id', current.location_package.getDisplayValue()); //if this is customf ield then it should be u_collection_id
collectionGr.query();
gs.addInfoMessage('preLoop');
}
catch(e)
{gs.info("Error: " + e);
}
gs.addInfoMessage('IAY in UI Action');
action.setRedirectURL(current);
}
Also collection_id referenced in line 18 doesn't looks to be OOTB field on incident table. If this is custom field then it should be u_collection_id. Please make changes and let me know.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 07:03 AM
Hi Ian,
gs.addInfoMessage() and setError() are both available in scoped applications.
It appears this example doesn't need a client component. In the interest of simplifying, can you try the server side code without the client code (uncheck the Client checkbox and reduce your script to just
runBusRuleCode();
function runBusRuleCode() {
// Your few lines
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 08:45 AM
Hi Chuck That does allow the Server Side code to execute but I seem to not be able to instantiate a new Glide Record
I receive an TypeError: undefined is not a function on either my custom table within the scoped application or a base table.
It is definitely running server side as I can see gs.info messages in the application log.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 08:48 AM
Can you copy/paste the entire script here? I feel like I'm only seeing part of the problem. Thanks. A screenshot of the entire UI action screen would also be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 09:24 AM
Here is the current entire script:
//Client-side 'onclick' function
//function runClientCode(){
//Call the UI Action and skip the 'onclick' function
// gsftSubmit(null, g_form.getFormElement(), 'Import Location Package'); //MUST call the 'Action name' set in this UI Action
//}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
//if(typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode(){
gs.addInfoMessage('IAY Package is ' + current.location_package.getDisplayValue());
try{
// var collectionGr = new GlideRecord('x_enig_extreme_quo_product_collection_location');
var collectionGr = new GlideRecord('incident');
gs.Info('INIT gr');
collectionGr.addQuery('collection_id', current.location_package.getDisplayValue());
collectionGr.query();
gs.Info('preLoop');
}
catch(e)
{gs.info("Error: " + e);
}
gs.info('IAY in UI Action');
action.setRedirectURL(current);
}