Issue with Email Client Templates and multiple email addresses
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 11:36 AM
Hi -
We've an email client template that we've set up for a particular catalog request item.
We would like the "To" address of this email client template to default to both the "opened_by" and "variables.requested_for" fields if they're different.
We've had email client templates working for years, and adding the conditions so that this particular email client template runs on this particular catalog request item seems to be working fine.
...
The problem is trying to put MULTIPLE values in this field when using javascript. How do you correctly separate the email values?
Here's our email script for the "To"(recipients) field:
javascript:
if(current.variables.requested_for.email!="" && current.opened_by.email=="") {
current.variables.requested_for.name+"<"+current.variables.requested_for.email + ">"
}else if(current.variables.requested_for.email=="" && current.opened_by.email!="") {
current.opened_by.name+"<"+current.opened_by.email + ">"
}else if(current.variables.requested_for.email!="" && current.opened_by.email!="") {
current.variables.requested_for.name+"<"+current.variables.requested_for.email + ">"+";"+current.opened_by.name+"<"+current.opened_by.email + ">"
}else{
""
}
The first 2 conditions work and send email just fine. The third - where it would send 2 emails at once - does not.
I've highlighted in red the problem character. If the character we put there is a semicolon, everything LOOKS like it works fine. The email popup has the users in the field, correctly displayed ("Name1; Name2;" etc), but the email doesn't SEND to them. In the email log, the Recipients field looks the same as most recipients fields, except the field separating the users is a semicolon instead of a comma. But these recipients never were actually added to the email header field in the email, so it didn't get to the appropriate folks, and ServiceNow says that was because "a semicolon in the recipients field is not supported, only a comma."
Ok, fine. So I try to do the same thing except use a COMMA, instead... And it then doesn't work correctly in the email popup; the To field ends up blank.
What IS the correct character to use here? Or, if there is no character that will work, how can I get the functionality I need?
Much thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 02:08 PM
Hi Rita,
A simple javascript array may do the trick. Once you've populated your array with the required emails values, pass the entire array as a string to the target variable using 'toString()'.
current.variables.emails = emailArray.toString();
Keep in mind that elements returned are separated by commas. Hope that helps.
- Leo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 03:08 PM
HI Leo -
No luck; same result as concatenating the comma manually; it doesn't work in the popup.
Thanks, tho!
-Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 07:41 AM
Another suggestion would be to break the concatenated email string down, run tests, then build it up slowly until you identify where the issue resides.
Within the action of the third condition:
- Try a single email (as you did in either of the first two conditions)
- Try replacing the email with only the comma separated string (without the names and greater or less than symbols)
The goal is to break things down to the point where you can clearly identify and isolate the issue, ...and if a bug is found, a ServiceNow HI ticket can be opened to have them patch it.
- Leo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 02:48 PM
Hi Leo -
The issue is there being 2 emails; when you put only 1 name/email combo (with "<>"s) in that condition, it works fine. The name followed by the semicolon appears in the email popup and the email is sent without issue.
I had actually already tried replacing the names with just the emails and commas yesterday, and no luck with that, either; the email popup still shows blank in the To field in that case.
The issue is that putting a semicolon between those fields makes it appear correct in the popup, but it doesn't send, and putting a comma between those fields makes it not appear correct in the popup, and there's no documentation on what character we SHOULD be putting between emails added in javascript formatted instead of those.
I appreciate your answering, though. Perhaps it is time to put in a SN bug.
Thanks,
-Rita