- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 12:28 AM
Hello community,
I created a mail script to pull to the notification the first name of the assignment group members, but I receive all the names like a whole string, I would like to separate each name with a comma.
This is my script:
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',current.assignment_group);
gr.query();
while(gr.next())
{
gs.print(gr.user.getDisplayValue('user'));
template.print(gr.user.name.split(','));
}
And this is how it looks:
Any clue about how to fix this? Kind regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 06:42 AM
Hi @PabloEugenG
You could add each name to an array and then join the array with a comma followed by a space. try this:
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', current.assignment_group);
gr.query();
var names = [];
while(gr.next()) {
names.push(gr.user.first_name);
}
// Join the names with a comma and a space
var namesString = names.join(', ');
template.print(namesString);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 06:42 AM
Hi @PabloEugenG
You could add each name to an array and then join the array with a comma followed by a space. try this:
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', current.assignment_group);
gr.query();
var names = [];
while(gr.next()) {
names.push(gr.user.first_name);
}
// Join the names with a comma and a space
var namesString = names.join(', ');
template.print(namesString);