Hi - I need to set a custom field for our clients users, who are not jira-software-users. We're using third party helpdesk plugin to work with them, and I need a custom scripted field to filter watchers. Client's users have "@" character in their usernames, so it's fairly easy. The problem is with User Picker templates - I can't get it to show any results.
I tried both single and multiple user template. Single always shows "anonymous" in script preview, and multiple basically shows nothing. Please advise. This is my script:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.watchers.IssueWatcherAccessor
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.ApplicationUsers
IssueWatcherAccessor iwa = ComponentAccessor.getComponent(IssueWatcherAccessor.class)
def list = iwa.getWatcherKeys(issue)
List filtered = new ArrayList();
for (user in list){
// IF/ELSE does the same for test purpose !!!
if(user==~ /.*@.*/){
filtered.add(ApplicationUsers.toDirectoryUser(ApplicationUsers.byKey(user)))
}else{
filtered.add(ApplicationUsers.toDirectoryUser(ApplicationUsers.byKey(user)))
}
}
List<ApplicationUser> clientWatchers = ApplicationUsers.from(filtered)
log.error clientWatchers
return clientWatchers
I'm loggin "clientWatchers" to see what it returns:
log.png
user picker (single user) shows Anonymous in script preview.
Zrzut ekranu 2016-06-02 o 18.23.29.png
BUT it does exactly the same whatever I return, example:
Zrzut ekranu 2016-06-02 o 18.27.52.png
and multiple user picker shows nothing:
Zrzut ekranu 2016-06-02 o 18.24.27.png
"test" custom field remains empty in issue view:
Zrzut ekranu 2016-06-02 o 18.21.48.png
Either I'm doing something wrong, or user picker templates are broken. Please advise.