Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can add user's email into a custom field?

Shah Baloch May 16, 2022

I want to add a Jira user's email to a custom field base on the selection of the user's display name from a custom drop-down field. There is a custom drop-down field "Contact Person" which has about 8 to 10 users. The name is the same as the Jira display name, but we added a custom field that users only can select those users.

The use case is that once the user selects a user (John Doe) from the dropdown field, it should add that user's email into a custom email field. I'll hide the email field from creating screen and it'll be only in the view screen. How can I achieve that?

 

def conPerson= getFieldById('customfield_10519')
def emailAddr= getFieldById('customfield_10520')
if(conPerson.value == 'John Doe') {
set emailAddr value to user's email
}

Thank you for your help

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Alex
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.
May 16, 2022

Hi @Shah Baloch 

How do you plan to implement that using a post-function or a listener to trigger at the create issue event?

Cheers 

Alex 

Shah Baloch May 16, 2022

I would like to have it in the initial stage like when the issue is created it should have the email address in the email field. 

Shah Baloch May 17, 2022

I was able to make it works with a behaviour script by mapping manually users' names with their emails. The problem is someone needs to maintain the script when there will addition and deletion of a user. I mean have to maintain the script when need to remove or add a member. I was looking if there will be an easy way to not maintain the script all the time?

def optionsConMap = [
   'User Name': 'user@email.com',
     'Some User': 'some@email.com'
]

def option = getFieldById('customfield_10519').value
def emailAddr = optionsConMap[option]
getFieldById('customfield_10520').setFormValue(emailAddr)

def email = getFieldById('customfield_10520')
email.setHidden(true)

 

Thank you for your help

TAGS
AUG Leaders

Atlassian Community Events