How to Display results from a script in a table (or similar)

riaz_mansuri
Kilo Guru

Hi,

I have a script which runs fine and displays the results well in the scripts Background.

How do I display the script results in service now as a page and have this script run daily?

   

var dupRecords = [];

    var gaDupCheck1 = new GlideAggregate('cmdb_ci_computer');

    gaDupCheck1.addQuery('model_category','laptop');

    gaDupCheck1.addAggregate('COUNT', 'asset_tag');

    gaDupCheck1.groupBy('asset_tag');

    gaDupCheck1.addHaving('COUNT', '>', 1);

    gaDupCheck1.query();

    while (gaDupCheck1.next()) {

          dupRecords.push(gaDupCheck1.asset_tag.toString());

    }

    gs.print(dupRecords);

 

Does not have to be anything fancy as long as it displays the results.

Thanks,

Riaz

1 ACCEPTED SOLUTION

Please replace 28 line with </li>.



Also, I agree with Kalai on this.


View solution in original post

14 REPLIES 14

Please replace 28 line with </li>.



Also, I agree with Kalai on this.


Top Job!! Thanks


Hi Gaurav,



This was very helpful and I now get my list



find_real_file.png



Any way I can make the Machine Names appear next to the numbers:



The field is called ci



find_real_file.png



Again doe snot have to look fancy


Hi Riaz,


gaDupCheck1 is the gliderecord object which is carrying all fields information in it. So you can just fetch out any field's value you need here.



${gaDupCheck1.asset_tag} - ${gaDupCheck1.newFieldName}C



Replace newFieldName in script with your field name.


Kalaiarasan Pus
Giga Sage

Do you not wish to address the root cause and stop adding duplicates by making asset_tag unique instead?


Jobs are usually for one time action, reminders etc. But I feel here, you should be addressing the root cause rather than adding more technical debt.