how to print in each value in a new line

Alon Grod
Tera Expert

Hi guys,

How can I print each value in the list in a new line?

var ci_list = [];

    var gr = new GlideRecord('incident');
    gr.addEncodedQuery('sys_created_by=azure_user^cmdb_ciISNOTEMPTY^business_serviceISEMPTY');
    gr.query();
    while (gr.next()) {
        var rel = new GlideRecord('cmdb_rel_ci');
        rel.addQuery('child', gr.cmdb_ci.toString());
        rel.query();
        if (!rel.next()) {

           var ci = gr.getDisplayValue('cmdb_ci');
           ci_list.push(gr.cmdb_ci.name);
        }
    }
    

    var uniqueCIs = new ArrayUtil().unique(ci_list);
    for (var i = 0; i < uniqueCIs.length; i++) {

        template.print(uniqueCIs[i] + ',    ');

    }

1 ACCEPTED SOLUTION

   @Alon Grod try this

template.print(uniqueCIs[i] + '<br>');

View solution in original post

5 REPLIES 5

Kalyani Jangam1
Mega Sage
Mega Sage

Hi, try to use

template.print("\n"+uniqueCIs[i] +"\n");

not working

Mohith Devatte
Tera Sage
Tera Sage

Hello @Alon Grod ,

just replace this line 

template.print(uniqueCIs[i] + '\n');

 

not working