Jira > Script Runner > Scripted fields: Is it possible to return certain Group by certain issuetype if reporter in more than one group?

Kristin Bestla April 25, 2013

Good Friday good People :)

I've created a Custom Field (with good help from the people at this forum ;) ), called Reporter Group, and that field is automatically filled out by Reporters User Group when an issue is created.

I ran into some issues to begin with, cause some users are in more than one group but got a solution to that. The reason for me doing this, is because I wanted to be able to see in a pie chart what group is reporting most / fewest defects.

I've put the script below so you can see how above mentioned it's done... BUT... now I'm wondering if I can change the script to set the Reporter Group field by an IssueType, for certain User Groups. For an example if a user is in two groups that I don't want to ignore, then the issuetype sets the field.

Fx. If I'm a reporter in two groups, one called jira-techsupport and another called jira-servicesupport, and if I report an issutype called techsupport, the reporter group is filled out as jira-techsupport, but if I report a regular bug (or something else than techsupport issue) the reporter group is filled out as jira-servicesupport, and this only applies if user is in those two groups, not he's in 'jira-qa' group etc.

Here is the script I'm using now, and works well, but would like to add the issuetype as mentioned above to it.

import com.atlassian.jira.ComponentManager

import com.atlassian.jira.security.groups.GroupManager

GroupManager groupManager = ComponentManager.getComponentInstanceOfType(GroupManager.class)

GroupList = groupManager.getGroupsForUser(issue.getReporterId()).name;

ignoredGroups = ['jira-users', 'jira-administrators'];

resultGroups = GroupList - ignoredGroups;

return resultGroups[0];

Best regards

Kristín

1 answer

1 accepted

1 vote
Answer accepted
Henning Tietgens
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.
April 25, 2013

You can get the issuetype with

issue.issueTypeObject.name

Henning

Kristin Bestla May 1, 2013

Thank you Henning :)

Suggest an answer

Log in or Sign up to answer