I'm trying to create a new project consisting all employees information.
there is information that found in the directory , and I need it too.
I am trying to write a groovy script that will get the email of a user given the specified username (User picker custom_filed ) .
But I don't know how to get the email that found in the user profile.
Hello @Yonatan Leket
It should be like this
import com.atlassian.jira.component.ComponentAccessor
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("Username").first()
def user = issue.getCustomFieldValue(customField)
def email = user.getEmailAddress()
Where you write your script? Is it postfunction or behaviour?
HI @Mark Markov,
I am trying to write a postfunction (scriptrunner Custom Script Field) ,
my goal is to get username's email after issue has been created,
This filed will be shown in View issue screen .
in case you think is better to do it in behaviour just let me know .
Thanks!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If i ve got you right. You need a script field that will be display email of user in Username field?
If i do, go to script fields, create one, place on view screens and place this script in.
import com.atlassian.jira.component.ComponentAccessor
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("Username").first()
def user = issue.getCustomFieldValue(customField)
def email = user.getEmailAddress()
return email
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I need script field that will be display email of user in Username field.
Do you know what can be the reason for this Error? see attached
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is static type checking error. You can ignore it. This is happens because compiler doesnt know return type of getCustomField method. But in runtime it will work, just check!:)
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.
You re welcome! If it helps you, please mark my answer as accepted. So that, other people will be able to find this answer easily for similar questions :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.