mail_script why does it not populate the cc field?

andy_dufresne
Tera Expert

Hello Gurus,

I created the following mail-script and tested in Scripts Background it is returning emails for sure:

find_real_file.png

Now In my email template I'm invoking it like this:

find_real_file.png

But when I click on email, it does not populate the cc list, can you help me?

find_real_file.png

Thanks in advance

1 ACCEPTED SOLUTION

Thanks to all who responded.   I finally solved it and this is how:



Firstly the email.addAddress thingy did not work, *but* what was working is if I put a field name say 'description' in 'to' field it would populate the value from description in the mail-template. So ..



  1. I created a new column say 'u_emailAddressHolder'
  2. Created a insert/update business rule that will update email addresses into this column based on my query
  3. Updated my template 'To' field with simply 'u_emailAddressHolder'


bingo all emails pop up.



I must give credit to Mr.David Hreben, who actually used this ingenious trick in the last message in here 🙂 Email Client  


View solution in original post

10 REPLIES 10

Hi Chuck,



Tried that as well, but cant see the cc and bcc list.   It did not let me send the mail without the to address so I put that 'test@abc.com'



find_real_file.png


This generates:


find_real_file.png



This


find_real_file.png



When I put it here in the template:


find_real_file.png



So I'm pretty sure the right script is getting called.      



Question more is how can this populate the cc fields?



btw: if I simply put this line in cc field it works:


find_real_file.png


it works as expected:



find_real_file.png



but a script does not work.



I'm sure I'm missing something in this puzzle!


I further tried with the following code [as it reutrns only one record].   I put this code in the Message Body, TO, CC, BCC:



<mail_script>


var user = new GlideRecord("sys_user");


  user.addQuery("notification", 2); //email


  user.addQuery("email", "!=", "");


  user.addQuery("sys_id","63c4d58cdb5a7200edfc7cbdae961936");


  user.query();




while (user.next()) {


          //add to cc list


          email.addAddress("to", user.email, user.getDisplayValue());


          //gs.print(user.email + user.sys_id);


}


</mail_script>


I further tried putting these in the to,cc,bcc fields respectively and additiionally all 3 of them in the body too.   Surprisingly, the body populated the emails but not the to/cc/bcc fields.  




${assignment_group.manager.email}


${source_ci.managed_by.email}


${source_ci.owned_by.email}


Quick update: I removed the '${' from above in   to/bcc/cc fields and the value emails showed up.   So some progress but not good enough yet