Widget code not working

David Cross
Tera Expert
Hello All, Can you please help me with this code; i am new to widgets.
its not showing the value in HTML div. what did i miss....
 
Html :-
<input type="text" ng-model="c.data.inc" class="form-control" aria-label="...">
<button type="submit" ng-click="c.searchD()" class="btn btn-primary">Search Incident</button>
<div ng-repeat = "key in data.arr">
  {{key.short_description}} => Why is this not displaying any values; 
</div>
 
 
Client Script:-
api.controller=function() {
  var c = this;
c.searchD = function (){
c.server.update();
}
}
 
Server Script:-
(function() {
data.arr=[];
if(input){
var gD = new GlideRecord('incident');
gD.addQuery('number',input.inc);
gD.query();
while(gD.next()){
var v ={};
v.short_description = gD.short_description;
data.arr.push(v);
console.log(v.short_description); >> This is showing the value
}
}
})();
1 ACCEPTED SOLUTION

Anirudh Pathak
Mega Sage

Hi @David Cross ,

You will need to pass the value of the short description to html using "getValue()".

Please update your server side script to below code - 

(function() {
    data.arr = [];
    if (input) {
        var gD = new GlideRecord('incident');
        gD.addQuery('number', input.inc);
        gD.query();
        while (gD.next()) {
            var v = {};
            v.short_description = gD.getValue('short_description');
            data.arr.push(v);

        }
    }
})();

 

 

View solution in original post

1 REPLY 1

Anirudh Pathak
Mega Sage

Hi @David Cross ,

You will need to pass the value of the short description to html using "getValue()".

Please update your server side script to below code - 

(function() {
    data.arr = [];
    if (input) {
        var gD = new GlideRecord('incident');
        gD.addQuery('number', input.inc);
        gD.query();
        while (gD.next()) {
            var v = {};
            v.short_description = gD.getValue('short_description');
            data.arr.push(v);

        }
    }
})();