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
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.