Scripted Custom Field User Picker Template always return Anonymous in Jira 8

Lukasz Sielski [cPrime] February 28, 2019

Hi,

 

I have the following code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser

def CommentManager = ComponentAccessor.getCommentManager()
if (CommentManager.getLastComment(issue)) {
def lastCommentAuthor = CommentManager.getLastComment(issue)?.getAuthorApplicationUser()
return lastCommentAuthor
}

it worked in previous Jira version and in jira 8 it is returning Anonymous 

 

When I change template to Text Field it return correct username. 

1 answer

1 accepted

1 vote
Answer accepted
Ivan Tovbin
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.
March 1, 2019

Hi Lukasz, 

Check the searcher for this field. Make sure it's set to 'User Picker & Group Searcher'. This should fix your issue.

Lukasz Sielski [cPrime] March 1, 2019

Hi Ivan, 

Thanks for reply. 


Please take a look at attached  screenshot,Screenshot from 2019-03-01 12-40-28.png

 

and the result when runned with text field 

Screenshot from 2019-03-01 12-42-54.png

To be honest I don't know what do you mean by "searcher for this field"

 

Best Regards,

Łukasz

Ivan Tovbin
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.
March 1, 2019

Ok,

Since you are returning an ApplicationUser in your script, you should set your field template to 'User Picker (single user)', exactly like you did in your first screenshot.

After you do that, you need to set the correct searcher (search template)  for your field.

Go to Admin > Issues > Custom Fields, find your field there and then click on the 'gear' icon to the right. In the opened menu click on "Edit". In the next screen select "User Picker searcher" in the "Search Template" field.

More info on configuring your custom fields can be found in this documentation.

Lukasz Sielski [cPrime] March 1, 2019

Yes! it works.

 

Thank You @Ivan Tovbin !

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events