
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2017 01:13 AM
I am looking into creating a utility script include that can be used across any widgets to be created for a specific application. I tried to test a basic call for the server-side script, the script include using GlideAjax, unfortunately, it's not working. I am using Istanbul instance.
Client-Scripting
var gTest = new GlideAjax('TDisplayMessage');
gTest.addParam('sysparm_name', 'displayMessage');
gTest.getXML(displayMessage);
function displayMessage(response){
alert(response.responseXML); <----- still the result is null (no XML received)
}
Script Include
var TDisplayMessage = Class.create();
TDisplayMessage.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
displayMessage: function(){
return "Hello Greeting!";
},
type: 'TDisplayMessage'
});
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2017 08:45 PM
Hi Nagendra,
Yes, I followed the steps mentioned in SN documents as well as verified the construction from other threads.
It seems there is a missing link, or a plugin that needs to be activated, or another script that should be imported in order to make GlideAjax work in the service portal widget.
Or, am I doing it wrong? Is there a different coding approach in the widget's client script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 02:43 AM
This has been resolved!
Points to consider:
1. Script include function(s) are only accessible in the Server Script of the widget. The class object can be directly initialized without using GlideAjax.
2. Client script calling Server Script method is possible using c.server.get
SCRIPT INCLUDE:
********************************************************************************************************************
var TestServerScriptOnLoad = Class.create();
TestServerScriptOnLoad.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
testServiceScriptOnLoad: function(){
console.log('Entered the script include--> TestServerScriptOnLoad');
},
type:"TestServerScriptOnLoad"
});
********************************************************************************************************************
SERVER SCRIPT:
********************************************************************************************************************
(function() {
console.log('See if this function is initially loaded.');
testOnLoad();
if(input){
if(input.action == 'getServerScriptMethod'){
console.log('Called from client script-->getServerScriptMethod:'+input.param);
}
}
})();
function testOnLoad(){
console.log('Check if this function is being called--testOnLoad()');
var ga = new TestServerScriptOnLoad();
ga.testServiceScriptOnLoad();
}
********************************************************************************************************************
CLIENT SCRIPT:
********************************************************************************************************************
function onLoad(){
var c = this;
console.log('Calling the client script of the widget.');
callServerScript(c);
}
function callServerScript(c){
c.server.get({
action:"getServerScriptMethod",
param:"ClientScript"}).then(function(response){}, callErrorMessage());
}
function callErrorMessage(){
console.log('Displaying error message.');
}
********************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 12:40 PM
In your research and testing, did you happen to come across anything about using glide ajax from a ui script included in the theme? I *think* glide ajax is either broken or intentionally not supported in all aspects of the portal even though i can find some community posts saying it is supported.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 10:02 AM
Well, synchronous Glide Ajax is not supported in Portal, asynchronous Glide Ajax works as usual.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2019 07:22 AM
I know this is REALLY old. The issue we were/are having is specifically when the ajax call (getXML, not getXMLWait) lives in script included in the portal's theme.
We got around it by PASSING the g_form object from the catalog client scripts into the included UI scripts.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2020 07:27 AM