Hello,
I am trying to extract the surname of a user in a post-function script from a custom field (User picker). The goal is to use it to automatically populate another field.
The custom field is called Head of Department. I can get the username like this:
issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Head of Department"))
The problem is, first, it is only the username, and second, somehow it is doublely written. If a username is paulsmith, the value returned from the command above is paulsmith(paulsmith). I don't know why the same value is repeated in the (). Anyway, is there a way to get to the firstname or surname based on the value of this field?
Cheers
Community moderators have prevented the ability to post new answers.
I think the following might work for you
issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Head of Department")).getName()
Thanks a lot! It helped get rid of the extra (username) and now I have only the username without redundant repetition. Is there any way to get to the firstname or lastname based on this value? I know a class UserUtils, but I couldn't find proper documentation how to apply it in such a case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cool!. Please mark the answer as correct so that other users can easily find it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this one
issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Head of Department")).getDisplayName()
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.