- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 06:30 AM
Hi All,
I have a requirement to create a Email client template which must have Emails from "XYZ" group , assume "XYZ" group has 10 users in it so in "TO" address of Template , these 10 users Email ID has to be populated.
To Achieve this ,i tried configuring "Script Include" and calling that script include in email client template.
Script Include:
var GetMIMCommunicationrecipients = Class.create();
GetMIMCommunicationrecipients.prototype = {
initialize: function() {},
getMIMRecipients: function() {
var emailList = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery('group.sys_idSTARTSWITH994098798713291066d4766acebb35bc');
gr.query();
if(gr.next()) {
gs.log('count'+gr.getRowCount());
emailList.push(gr.user.email);
}
return emailList;
},
type: 'GetMIMCommunicationrecipients'
};
Can any one please suggest how to achieve this.
Appreciated your response Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 06:37 AM
Can you share your template record? You must put the call in there.
javascript: new GetMIMCommunicationrecipients().getMIMRecipients()
Also the script must return a comma separated string of email addresses, so you would update your method to the below.
var GetMIMCommunicationrecipients = Class.create();
GetMIMCommunicationrecipients.prototype = {
initialize: function() {},
getMIMRecipients: function() {
var emailList = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery('group=994098798713291066d4766acebb35bc');
gr.query();
while(gr.next()) {
emailList.push(gr.user.email);
}
return emailList.join(",");
},
type: 'GetMIMCommunicationrecipients'
};

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 06:37 AM
Can you share your template record? You must put the call in there.
javascript: new GetMIMCommunicationrecipients().getMIMRecipients()
Also the script must return a comma separated string of email addresses, so you would update your method to the below.
var GetMIMCommunicationrecipients = Class.create();
GetMIMCommunicationrecipients.prototype = {
initialize: function() {},
getMIMRecipients: function() {
var emailList = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery('group=994098798713291066d4766acebb35bc');
gr.query();
while(gr.next()) {
emailList.push(gr.user.email);
}
return emailList.join(",");
},
type: 'GetMIMCommunicationrecipients'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 09:07 AM
Hi @Elijah Aromola ,
Thanks for your Reply,
This is the Email Client Template.
And after adding below line, i am able to get only one email on Template, please let me know where the changes has to be made.
"return emailList.join(",");"
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 09:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 09:32 AM
You need to change your code from an "if" to a "while". See my code from above.