Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Display reporter group membership in a ticket

Bojan Virag
Contributor
May 25, 2023

I want to display department of a reporter in a ticket.

Each user is a member of a jira group in format e.g. "department-sales".

We have a lot of departments so I do not want to manually write each department an a automation rule and worry about keeping it up to date. 

I'm thinking if it's possible to write a groovy script that would do something like:

If user is a member of group department-* then custom field Department = group name.

Or any other ideas how I could display single group membership in a ticket?

Without additional plugins.

 

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Peter-Dave Sheehan
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.
May 25, 2023

Yeah, that could work.

If you already have your department field, I would put this in the workflow "create" transition as a post function. Or in a listener for catching when the reporter changes.

If you don't already have a department field, you could create a new script field.

But ultimately, here is a snippet of code for getting the list of groups for a user (assuming you already have an issue object).

 

ComponentAccessor.userUtil.getGroupNamesForUser(issue.reporter.name).findResults{groupName->
if (!groupName.startsWith('department')) return null //exclude groups that don't start with department
groupName.replaceAll('department-', '') //return just the department
}.join(', ') //in case there is more than 1
Bojan Virag
Contributor
May 30, 2023

That is awesome, thank you! I'll give it a try.

0 votes
Bojan Virag
Contributor
May 30, 2023

Worked like a charm, thanks again for your help!

TAGS
AUG Leaders

Atlassian Community Events