Hello,
My JIRA setup contains custom field "Team". Also user groups have been created and their names exactly corresponding "Team" values. Based on this assumption I need to check whether the issue assignee belongs to the user group.
I made groovy script
MutableIssue issue = issue componentManager = ComponentManager.instance customFieldManager = componentManager.getCustomFieldManager() userUtil = componentManager.getUserUtil() cfTeam = customFieldManager.getCustomFieldObjectByName("Team") teamUserGroup = issue.getCustomFieldValue(cfTeam) assigneeUserName = issue.getAssigneeUser().getName() if (userUtil.getGroupNamesForUser(assigneeUserName).contains("TEAM1")){ System.out.println("Assignee is in the Team Group! " ) }
and it works well if Team is exclitely mentioned as "TEAM1", but if I use value taken from custom field, i.e.
if (userUtil.getGroupNamesForUser(assigneeUserName).contains(teamUserGroup))
it returns the error
javax.script.ScriptException: javax.script.ScriptException: java.lang.ClassCastException: java.lang.String cannot be cast to com.atlassian.jira.issue.customfields.option.Option
I think solution should be trivial, but didn't manage to resolve it.
Could you please help?
Best regards, Georgiy
Replace
teamUserGroup = issue.getCustomFieldValue(cfTeam)
with
teamUserGroup = issue.getCustomFieldValue(cfTeam).toString();
Do null checks and stuff.
toString or getValue as Henning suggested. Just saw it!
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, that was mistake.
I used
teamUserGroup = issue.getCustomFieldValue(cfTeam).toString();
and it works!!!
Thank you very much!
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.