Passing variables from Client to Server side in Widget with Augular?

georgechen
Kilo Guru

Hi folks,

I am stuck at a widget where a client side script is having difficulty to pass variable to the server, wondering if I could get any advice?

I have a widget "Data table 3" consisting of Server/Client scripts.   In the client side, a variable c.data.c_topic need to pass to the server (see the highlighted below)

find_real_file.png

In the server side, try to display the variable by gs.addInfoMessage

find_real_file.png

As it can be seen, the data.c_topic shows as undefined.

find_real_file.png

I may need more details please let me know if so.

Thanks

7 REPLIES 7

Thank you very much and do you know how to call ajax call from custom widget?



The ajax script include works just fine when I call it from incident form after adding onLoad() script include to the incident form.


However, when I try to call from custom widget nothing nothing happens, but throws error in the console.



/************* Ajax Script Include **************/



var BDO_Get_KowledgeBases_ID = Class.create();


BDO_Get_KowledgeBases_ID.prototype = Object.extendsObject(AbstractAjaxProcessor, {



get_kb_ID: function(){


return ("Thanks for your help Ujjawal Vishnoi....");


},



      type: 'BDO_Get_KowledgeBases_ID'


});



/************* Widget Client Script **************/




var ga = new GlideAjax('BDO_Get_KowledgeBases_ID'); // calling ajax


ga.addParam('sysparm_name','get_kb_ID');   // calling get_kb_ID method that defined above


ga.addParam('sysparm_kb_sys_id',"1bfe72f2de72f2dbfe4e72f2dbfe4bfe4"); // passing "sysparm_kb_sys_id"


ga.getXML(Get_KB_ID); // calling callback function



// the callback function for returning the result from the server-side code


function Get_KB_ID(response) {


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


alert(answer);


}




Thanks for your help


Dave Jookhuu


ashishburman
Giga Contributor

in client 

c.data.x="some data";

 

in server 

 

you will get the value of x as input.x

 

tantony
Mega Guru

On a quick look I see have gs.addInforMessage() instead of gs.addInfoMessage(). Should that be the problem?