data from server to client Service Portal Widget

chidanandadhath
Kilo Guru

I want to pass Trouble shooting number from server to client below is the code

Note : Scoped application

HTML

<div class="panel panel-default panel-body m-t m-b">
<button class="btn btn-primary btn- block" ng-click="c.execute()">Execte Error Code</button>
</div>

 

Client script 

function() {
// /widget controller /
var c = this;
c.execute= function(){
c.server.update().then(function(response){
c.data ={};
alert(c.data.troubleshooting);


})
}}

 

Server Script

 

(function() {

var gr = new GlideRecord('x_qune_ca_troubleshooting');
gr.initialize();
gr.insert();

var strTroubleShootingNumber = gr.number;
gs.eventQueue('x_qune_ca.execute_analysis', gr, strTroubleShootingNumber, '');
gr.status = 'analyzing_cmdb_logs';
gr.update();

troubleshooting={};
troubleshooting.strSysID = gr.sys_id;
troubleshooting.strTroubleShootingNumber = gr.number;

})();

 

1 ACCEPTED SOLUTION

chidanandadhath
Kilo Guru

Got t..need to use gr,getValue('number');

View solution in original post

8 REPLIES 8

Mike Patel
Tera Sage

did you tried

alert(c.data.troubleshooting.strTroubleShootingNumber);

or

alert(c.troubleshooting.strTroubleShootingNumber);

tried this but no luck

can you remove c.data ={}; before alert

Vijay Pawar3
Tera Contributor

Hello,

You will have to put troubleshooting number in data object on server side, like

data.troubleshootingnumber = gr.number;

data object is passed from server side to client side and input object is passed from clienside to serverside.