Using smart values in the sending email's recipient
Asked by Denny Pujo:

Hi, I added a dropdownlist field into my issue type. The options for the dropdownlist are "Internal" and "External". The field name for this dropdownlist is "Notification Type".

Then I created an automation that would send an email, and the "To" field is based on the "Notification Type". so this is how I write the "To" field

{{#if(eq({{Notification Type}}, "Internal"))}} xxxx@xxxx.xx.xx{{/}}

then when I tried it, in the issue logs, it shows that   
"Could not send email, the 'To' address field is empty. If you have referenced a field it may be empty."  

What could be wrong in here? Thank you


Answers:
author: Curt Holley
body: I would use a if else condition to handle your custom field,

If Notification type = Internal do whatever

Else Notification type = External do whatever

but then, how/where are you getting your email addresses from?

comments: author: Denny Pujo
body: how to use the if else condition?  
actually I'm following this link <https://community.atlassian.com/t5/Automation-articles/New-automation-smart-values-in-Jira-Cloud/ba-p/1402775> which stated multiple IF rather than IF Else.  

<br />

what I want to do, when (Notification type = Internal), then I will input the list of emails manually. something like this  

{{#if(eq({{Notification Type}}, "Internal"))}} xxxx@gmail.com{{/}}  
{{#if(eq({{Notification Type}}, "Internal"))}} yyyy@gmail.com{{/}}  
{{#if(eq({{Notification Type}}, "External"))}} aaaa@gmail.com{{/}}  
{{#if(eq({{Notification Type}}, "External"))}} bbbb@gmail.com{{/}}  

but above is not working


author: Denny Pujo
body: ![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/200235i2E339D7A68F27EA6/image-size/large?v=v2&px=999 "image.png")


author: Curt Holley
body: I don't think putting all of that in the "To" section will work.

What does the rest of your automation look like (what conditions?)

What happens if you just put the relevant email addresses in? as, although smart values are supported in the "To" field, my hunch is, the net result of using any in there would have to simply = "an email address" and all other logic needs to be handled in the conditions of the rule.


author: Denny Pujo
body: The condition is an issue is transitioned to another status. I think I get what you mean, let me try it first.


author: Simmo
body: Hi [@Denny Pujo](/t5/user/viewprofilepage/user-id/4946259),

An interesting one this one! So, the reason that it isn't working is that I think when the smart value doesn't match you get an empty string as one of the addresses and that doesn't go down well.

What I think you could do is to use the Create Variable action to get a smart value and then use that smart value.

Your smart value could be something like:

```
{{#if(eq({{Notification Type}}, "Internal"))}}xxxx@gmail.com, yyyy@gmail.com{{/}}{{#if(eq({{Notification Type}}, "External"))}}aaaa@gmail.com, bbbb@gmail.com{{/}}
```

But I think it is important that you keep it on one line. If you use that in a Create Variable action and then refer to that as one smart value in the email action it should work.

Cheers,

Simeon.


author: Denny Pujo
body: Hi Simmo, thank you for the reply. Actually Curt already helped me with this one. Because I didnt know that the automation could also use an If else into the logic itself. Now im using the automation's build in if else logic, and it is actually much more easier to read.