Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to call server side data on html side?

Sin
Giga Expert

Guys am trying to show `name` field from `announcement` table on html side using `<marquee></marquee>` field.

Server script: 

(function() {

var announce=new GlideRecord('announcement');
announce.addQuery('active=true');
announce.query();
while(announce.next()){
data.announcement= announce.name;
console.log(data.announcement);// got data here
}
})();

 

HTML code:

<div>

<marquee>{{data.announcement}}</marquee>

</div>

 

I am not getting the data on html code. What I did wrong here?

If I have multiple datas on name field how can I loop it?

1 ACCEPTED SOLUTION

Sin
Giga Expert

The following code worked me for showing marquee data from array and object.

serverside:

 

(function() {
data.arr = [];
var announce=new GlideRecord('announcement');
announce.addQuery('active=true');
announce.query();
while(announce.next()){
var record={};
var display_value='';
display_value = announce.getValue('name') ;
record.display_field=display_value;
data.arr.push(record);
}

})();

 

Html side:

 

<div>
<marquee><b ng-repeat='val in data.arr'><label>{{val.display_field}}</label></b></marquee>
</div>

View solution in original post

13 REPLIES 13

Omkar Mone
Mega Sage

Hi 

Try with "c.data.announcement" once.

Hi 

Do this too 

{{::data.announcement}}

getting same issue:-(

 

Hi 

I have done a simple testing and here it is :- 

find_real_file.png

 

I suggest you to do this before GlideRecord ,

data.announcement = '';