Array values are not getting printed correctly
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Hi,
I need a help regarding a Background script.
I need to fetch and print first 5 users from each Department the User table. Below is the script that I have written.
var dep = new GlideAggregate('sys_user');
dep.addNotNullQuery('department');
dep.groupBy('department');
dep.query();
while(dep.next())
{
var dept = dep.department;
gs.print("Department is " + dept.getDisplayValue());
var array = [];
var user = new GlideRecord('sys_user');
user.addQuery('department',dept);
user.orderBy('name');
gr.setLimit( 5 );
user.query();
while(user.next())
{
array.push(user.name);
}
gs.print(array);
}
After running the script, it gives output as attached. Please help me to find what is wrong with my script.
Thanks,
Kiruthikroshan M
0 REPLIES 0
