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

How to set assignment group to CC through email script

ronaldanand
Tera Contributor

Hi All,

I want to set assignment group value to email CC, I have tried below script and  logs also showing the group name but

email CC value notreflecting the value. please check and help me

 

event.parm2 ==> INC000001 * Groupname </br> ,

                             INC000002 * Groupname2</br>,

(function runMailScript(current, template, email, email_action, event)
 {
    var userGroup = (event.parm2 + '').split('*');
      var groupSysID = userGroup[1];
    var user1,grup ;
    
    var sgid = groupSysID.indexOf("</br>");
    var grpid = groupSysID.substring(0,sgid);
    
     gs.log("test4 :" +grpid);
    
      //add to cc list    
      email.addAddress("cc",grpid.getDisplayValue()); // any thing wrong for this lines
})(current, template, email, email_action, event);

 Thanks in Advance

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

You need to add the email id while using addAdress.

 

So if they have a group DL, you should use that

email.addAddress("cc",grpid.email); 

 

Otherwise you will have to loop thru all the members of the group and add their email id to CC


Please mark this response as correct or helpful if it assisted you with your question.

Raj68
Mega Guru
 Hi Ronaldanand,
 
Please try below code to achieve your requirement:

try{

email.addAddress("cc", current.assignment_group.email.getDisplayValue(),  current.assignment_group.getDisplayValue());

 

}

catch(err){

gs.log(current.assignment_group.email.getDisplayValue(),  current.assignment_group.getDisplayValue()));

}

 

NOTE: Mark correct or helpful if it helps you.

 

Warm Regards,

Raj patel

 

Hi There,

I have to implement the same but the group dont have group email.

Thanks,

Snehal

Sailesh4
Giga Expert

Hi Guys,

This probably might be an old post. I was just checking for the similar one, and couldn't find the relevant code. Below is what I have written and it worked perfectly for me.

var a = new GlideRecord('sys_user_grmember');
a.addQuery('group', current.assignment_group);
a.query();
while (a.next()) {
    email.addAddress("cc", a.user.email, a.user.name);
}

If it works for you please mark it as Corrected or Helpful and complete the loop.

Thanks,
Sailesh