e-mail address instead of username

Luca Poltera July 12, 2021

Hi there

 

We have created an e-mail template in jira.
Is there a way to have the repoter/assignee (or custom field (pick user)) show the email address of the user and not the username?

 

(Jira on Premise)

 

Thank you!

Best Regards

 

2 answers

1 accepted

0 votes
Answer accepted
Daniel Ebers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 16, 2021

Hi @Luca Poltera

assuming they are not batched notifications (they work a bit different) it should be possible - however, I have no ready-solution but probably something you could investigate further.

Judging by the path you mentioned I believe you are not using batched notification so the following could be a start.

I read here: https://community.atlassian.com/t5/Answers-Developer-Questions/How-do-I-display-the-full-name-of-a-user-picker-custom-field-in/qaq-p/491290

about an example: ($issue.getCustomFieldValue("customfield_10094").name)

It could work - when the value "name" is replaced by the matching part for e-mail. Just a guess: you could try something similar with .email or probably .emailAddress (in Community there can be found information that the one or another worked in the past - however, I suspect there were additional Apps involved, why it might be it will not work for you, unfortunately).
Of course, please adapt the said above to your template.

If it does not work a solution could probably be to fetch the mail address with some kind of scripting solution and put it to a dedicated custom field of type "email". This should be easier to access via Velocity templates. However, I recognize this would require an App and you have not stated if you have one in your instance (probably not willing to pay another one) - also, it would be a quite hacky way.
Would be interested in what you find out!

Regards,
Daniel

Luca Poltera July 22, 2021

Hi

Thank you very much for your answer

 

i tried with .email and .emailAddress and i got

.emailAddress = Anonymous

.email = unassigned

 

I have to investiged more, I will get back to you as soon as I have news.

Luca Poltera July 22, 2021

Hi @Daniel Ebers 

@Dave Bosman _Realdolmen_ 

 

i tried again, and now it works. 

i used: (user picker customfield)

#text($issue.getCustomFieldValue("customfield_10200").emailAddress)

my whole customfield.vm looks like:

#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_10200"))
#if($issue.getCustomFieldValue("customfield_10200").name)
<tr>
<th>#text($customfield.name):</th>
<td class="has-icon">
#text($issue.getCustomFieldValue("customfield_10200").emailAddress)
</td>
</tr>
#end 

 

if you would like to show the whole username:

#authorlink($issue.getCustomFieldValue("customfield_10201").name)

#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_10201"))
#if($issue.getCustomFieldValue($customfield))
<tr>
<th>#text($customfield.name):</th>
<td class="has-icon">
#authorlink($issue.getCustomFieldValue("customfield_10201").name)
</td>
</tr>
#end

im not a developer, so there can be some mistakes, use at your own risk :)

 

Best Regards

Luca 

Daniel Ebers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2021

Great - I'm glad you got it solved!

0 votes
Dave Bosman _Realdolmen_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2021

Hi @Luca Poltera 

You can edit the template files on server level, but i'm not sure that you can implement this specific thing. 

I never did i myself and i always recommend customers not to edit those as this would mean that with every upgrade you need to modify all the templates again. 

Regards

Dave

Luca Poltera July 12, 2021

Hi @Dave Bosman _Realdolmen_ 

 

Thank you for your response.

I edited the templates here :

/opt/atlassian/jira/atlassian-jira/WEB-INF/classes/templates/email/html/

Till now, i was not able to create a custom field (pick user) with e-Mail address.

Is there any code or script which can be added to the custom-filed (customfield.vm) with that i can catch the e-mail address of a user?

 

Best Regards

Suggest an answer

Log in or Sign up to answer