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

tried this..but I'm getting "undefined"

chidanandadhath
Kilo Guru

I modified Client script like below

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

  and server as 

(function() {


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

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

data.troubleshooting=gr.number;

})();

getting 

[object Object]

chidanandadhath
Kilo Guru

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

Vijay Pawar3
Tera Contributor

good, please mark answer correct/helpful, if it helpled you. 

thanks.