I am currently testing an upgrade from Jira 5.2.7 to Jira 6.2.2
In the jira 5.2.7 we have several scripted fields that ready the Jira Users Account Properties meta-data and displays it in a Scripted Field on a issue.
For Example - in the user account - Jira User. Defined property (Manager - John Doe)
Here is the currently working Jira 5.2.7 scripted field -
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.UserPropertyManager;
UserPropertyManager userPropertyManager = ComponentAccessor.getUserPropertyManager();
String propKey = "public Manager";
String propValue = null;
User u = getCustomFieldValue('Customer')
if (u) {
propValue = userPropertyManager.getPropertySet(u)?.getString('jira.meta.'+propKey);
}
return propValue;
Now, when I upgraded Jira to 6.2.2, this field no longer works and returns an error -
javax.script.ScriptException: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'ahughes(ahughes)' with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User' A stacktrace has been logged.
Did Jira 6.2.2 change the Crowd API statement? Is there a 6.2.2 version that would work?
Thanks in advance,
Andre
Something like this:
import com.atlassian.jira.user.ApplicationUsers if (u) { def dirUser = ApplicationUsers.toDirectoryUser(u) ... then use dirUser not u
untested
I tried changing it to the following -
import com.atlassian.jira.user.ApplicationUsers;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.UserPropertyManager;
UserPropertyManager userPropertyManager = ComponentAccessor.getUserPropertyManager();
String propKey = "public Manager";
String propValue = null;
User u = getCustomFieldValue('Customer')
if (u) {
def dirUser = ApplicationUsers.toDirectoryUser(u);
propValue = userPropertyManager.getPropertySet(u)?.getString('jira.meta.'+propKey);
then use dirUser not u;
}
return propValue;
However it still returns the error -
javax.script.ScriptException: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'ahughes(ahughes)' with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User' A stacktrace has been logged.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Change
User u = getCustomFieldValue('Customer')
to
def u = getCustomFieldValue('Customer')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"then use dirUser not u;"
was a comment for you not code.
To be more specific, change
propValue = userPropertyManager.getPropertySet(u)?.getString('jira.meta.'+propKey);
to
propValue = userPropertyManager.getPropertySet(dirUser)?.getString('jira.meta.'+propKey);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you it worked - here is the final version -
import com.atlassian.jira.user.ApplicationUsers;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.UserPropertyManager;
UserPropertyManager userPropertyManager = ComponentAccessor.getUserPropertyManager();
String propKey = "public Manager";
String propValue = null;
def u = getCustomFieldValue('Customer')
if (u) {
def dirUser = ApplicationUsers.toDirectoryUser(u)
propValue = userPropertyManager.getPropertySet(dirUser)?.getString('jira.meta.'+propKey);
}
return propValue;
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.