The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GlideAjax is not working in Service Portal Widget (Istanbul)

brian_corpuz
Tera Expert

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'

});

1 ACCEPTED SOLUTION

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?


View solution in original post

9 REPLIES 9

Ujjawal Vishnoi
Mega Sage
Mega Sage

Hi Brian,



If you are creating any utility then you should call that script include(by creating an object of script inclue) in server script of widgets and then we can use the value in client side as well.



Hope this helps.



Regards


Ujjawal


Hi Ujjawal,



Appreciate the response.



Well, this is a good idea but has negative impact in the future. This utility is to be used by multiple widgets, if I am to put into the server script, I need to do the same coding for the rest of the widgets.



I am creating a single utility which can be used across all the widgets that will be using it. If there is any modification, I only need to modify 1 set of code instead of modifying the widgets affected by the changes.



Hope I am able to give you the picture of my idea in this question.


sbrnag
Mega Expert

Hi Brian,



      Did you checked the Client Callable option in Script Include ?



find_real_file.png



And also update your code as below to get proper response



var gTest = new GlideAjax('TDisplayMessage');


gTest.addParam('sysparm_name', 'displayMessage');


gTest.getXML(displayMessage);



function displayMessage(response){


    var answer = response.responseXML.documentElement.getAttribute("answer");


  alert(answer);


}



Thanks,


Nag.


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?