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

Kannan Nadar
Tera Guru

Hi George,



How are you trying to pass the variable? You would have to use GlideAjax. Checkout the below training material provided by ServiceNow.



https://developer.servicenow.com/app.do#!/training/article/app_store_learn_advanced_ui_helsinki_c_Mo...



Thanks,


Kannan


Hey Kannan


I am trying to pass it in Angular.



find_real_file.png


Hi George,



You can use c.server.update to send the data to server as mentioned below.



function($scope) {  


      var c = this;


  c.data.abc='Any Name';


      c.update = function() {


              c.server.update().then(function (response) {


  c.data = {};


  })


      }


}



Server side you can use


if(input)


{


gs.log(input.abc);


}


else


{


//Code for intial load


}



Hope this helps.



Regards


Ujjawal


Thank you very much!