- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 06:06 AM
Hello Gurus,
I created the following mail-script and tested in Scripts Background it is returning emails for sure:
Now In my email template I'm invoking it like this:
But when I click on email, it does not populate the cc list, can you help me?
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2017 02:29 AM
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 ..
- I created a new column say 'u_emailAddressHolder'
- Created a insert/update business rule that will update email addresses into this column based on my query
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 06:42 AM
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'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 07:16 AM
This generates:
This
When I put it here in the template:
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:
it works as expected:
but a script does not work.
I'm sure I'm missing something in this puzzle!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 08:20 AM
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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 05:55 AM
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}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 05:58 AM
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