How to print the Array values in New Line in ServiceNow Portal

Vidya Lakshmi
Kilo Sage
Kilo Sage

Hello All,

Im trying to send the array values from script include to Server Script.

When i send from Script include i can see that the array values are getting sent in New Line.

find_real_file.png

I get the array values in the Server script and trying to print in the HTML portion.

So in the portal, the array values don't get printed in new lines.

find_real_file.png

Here is the Server Script :

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if(input.val){
gs.log('value is'+input.val);
gs.addInfoMessage('Message is'+input.val);
data.a=new getValues().Application(input.val);
gs.addInfoMessage("server" + data.a);
}})();

Here is the HTML Code :

<div>
<p> Applications : </p>
{{data.a}}
</div>

any help on how to print the array values in new line ????

 

1 ACCEPTED SOLUTION

Navjot Singh
Giga Contributor

This might be helpful

find_real_file.png

View solution in original post

3 REPLIES 3

Mike Patel
Tera Sage

did you tried

gs.addInfoMessage("server" + data.a + "\n");

Navjot Singh
Giga Contributor

This might be helpful

find_real_file.png

Hey Navjot,

This really helped a lot.

Thanks for this.

Also i need one more help.

How can I add the select box beside every application which has few values in it.??

Thanks in Advance.