Yesterday I wrote a custom script that was returning a user based off a userName and it was working. This morning I ran the same code and it was returning Anonymous User. I simplified the code just to return me a static user and return it, and it still returns the Anonymous User.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser
ApplicationUser u = ComponentAccessor.getUserManager().getUserByKey("XXXX")
return u
Some things I have verified with the above code snippet:
* XXXX is my username in jira (what I use to login with - omitted for security)
* The Template type is "User Picker (single user)"
The interesting thing is that when I change the template type to "Text Field (multi-line)", and do the following:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser
ApplicationUser u = ComponentAccessor.getUserManager().getUserByKey("XXXX")
return u.getDisplayName()
I get what I expect. My full name
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser
ApplicationUser u = ComponentAccessor.getUserManager().getUserByKey("XXXX")
return u.getEmailAddress()
I get what I expect. I get my email address
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser
ApplicationUser u = ComponentAccessor.getUserManager().getUserByKey("XXXX")
return u.getUserName()
I get what I expect. My original input "XXXX"
Either something really bad is happening here, or I'm missing something really simple. Can someone please help out?