Use email address from description and set it as request participant
Asked by Mehran Ahmadi:

Hi all,  

how can I use/copy an email address which is mentioned in the description and set it as a request participant via automation?  

The e-mail address is written like below.  

E-Mail Adresse =...  

Thank you for your time and attention,  
I do appreciate your feedback.  

Kind Regards Mehran


Answers:
author: Darryl Lee
body: [@Bruno Altenhofen](https://community.atlassian.com/t5/user/viewprofilepage/user-id/4428105) wrote a whole article on how to do exactly what you're trying.

* [Populate a user picker field from the description field](https://community.atlassian.com/t5/Jira-Service-Management-articles/Populate-a-user-picker-field-from-the-description-field/ba-p/2134905)

Sorry about the earlier journey to get to the exact same place.


author: Darryl Lee
body: Hi [@Mehran Ahmadi](/t5/user/viewprofilepage/user-id/2322738) -

So I think this should work, using the [match operator](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--) for smart values:

```
{{issue.description.match(".*E-Mail Adresse =(.+).*")}}
```

Ah, one catch is that I entered an email address via the GUI, which converted it into a link. So my code above extracts the address as Jira markup for the "link":  

```
[test@notarealemaildomain.com|mailto:test@notarealemaildomain.com]
```

So I revised the smart value to only parse the text version of the description:

```
{{issue.description.text.match(".*E-Mail Adresse =(.+).*")}}
```

And this only returned the email address:  

```
test@notarealemaildomain.com
```

FYI, for testing this, I used a Manual trigger and used the automation audit log. This is a really powerful way to debug automation rules. There's good details on this here:

* [Debug an automation rule](https://support.atlassian.com/cloud-automation/docs/debug-an-automation-rule/)

comments: author: Darryl Lee
body: Oh, because I have a tried lot of add-ons that generated service accounts, I did want to show how you might need to scroll through list of accounts before you can see the Smart Value at the bottom of the list when trying to use it for **Request participants**.

![Screen Shot 2023-03-14 at 2.07.27 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/245582i80BDD5C63205878B/image-size/large?v=v2&px=999 "Screen Shot 2023-03-14 at 2.07.27 PM.png")


author: Darryl Lee
body: Ugh. Further complications.

I think Request Participants cannot be added by email!

When trying to add an active user by email address, I'm seeing this in my logs:
> Inactive user
>
> fb-test@darryl.com

So uh, that's not great. Oooof, of course the estimable [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) has already run into this issue.

* [Automation to Add Request Participant from Email field](https://community.atlassian.com/t5/Jira-questions/Automation-to-Add-Request-Participant-from-Email-field/qaq-p/1821750)

So... the big question here is, is the email address in the Description an existing Customer or User, or a new Customer?

If it is a new Customer, then you could possibly follow instructions on that question to create a new Customer, do a couple of Re-fetches, and then grab the Customer accountId to add it as a Request Participant.

Unfortunately probably due to GDPR, I don't think there is a way to lookup the accountId of an existing user or customer by email. Does that sound right to you, Bill?


author: Darryl Lee
body: Ugh, I spoke too soon. There **is** a way with the [Find Users](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-user-search/#api-rest-api-3-user-search-get) API:

<https://YOURSITE/rest/api/3/user/search?query=fb-test@darryl.com>

So then, this rule got a lot more complicated, because you'll need to use a [Web request action to the Jira API](https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828) to try looking up the email address to see if it has a corresponding accountId, and if so, adding to the issue that using [Advanced editing with JSON](https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Request-participants).

**Wait wait!** [@Bruno Altenhofen](/t5/user/viewprofilepage/user-id/4428105) wrote a whole article on how to do exactly what you're trying.

* [Populate a user picker field from the description field](https://community.atlassian.com/t5/Jira-Service-Management-articles/Populate-a-user-picker-field-from-the-description-field/ba-p/2134905)

Wow, I could've saved myself a lot of time just linking to that!


Tags: participant

request