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

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

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
Henning Tietgens Community Champion Apr 25, 2013

You can get the issuetype with

issue.issueTypeObject.name

Henning

Thank you Henning :)

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,293 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot