The CreatorCon Call for Content is officially open! Get started here.

How to send mail to a group using workflow notification script ?

Beast
Tera Contributor

I have create a catelog item. it has a dropdown variable which contains the name of some groups. 
in the workflow notification how can i send mail to the groups which user select in the variable.

find_real_file.png

find_real_file.png

I tried the above, but not working..

 

Please help me

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hey @Beast 

Hope you are using Approval - Group activity

Try below code:

var grp = current.variables.group;
var gr = new GlideRecord("sys_user_group");
gr.addQuery("name", grp);
gr.query();
if(gr.next()){
    answer.push(gr.getUniqueValue());
}

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

 

Best Regards
Aman Kumar

View solution in original post

8 REPLIES 8

Mohith Devatte
Tera Sage
Tera Sage

Hi @Beast ,

try this script

var answer = [];

var arr = current.variables.group.toString().split(',');
for(var i=0; i<arr.length; i++)
{
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',arr[i]);
gr.query();
while(gr.next())
{
	answer.push(gr.user.toString());
}
}

Hope this helps 

PLEASE MARK MY ANSWER CORRECT IF THIS HELPS YOU

How can i change the script, if the variable is a cmn_department reference filed.

And i want to send the mail to the users in the department

Aman Kumar S
Kilo Patron

Hey @Beast 

Hope you are using Approval - Group activity

Try below code:

var grp = current.variables.group;
var gr = new GlideRecord("sys_user_group");
gr.addQuery("name", grp);
gr.query();
if(gr.next()){
    answer.push(gr.getUniqueValue());
}

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

 

Best Regards
Aman Kumar

How to push 2 groups ? 

And also can you provide a solution if it is a department (cmn_department)

I want to send notification to a department