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

Scripted post function to assign JIRA issue to a reporter

Niranjan
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.
August 7, 2018

Hi All,

We have a requirement where we would need to assign issues to the reporter, if the reporter belongs only to one specific role. Could someone help with the scripted post function for the same. 

Assume, if the reporter is a 'Tester' then the issue needs to be assigned to him. If he has any other different role, then the assignment should not work. 

 

Regards

Niran

2 answers

1 accepted

0 votes
Answer accepted
Mark Markov
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.
August 7, 2018

Hello @Niranjan

You can use ScriptRunner to achieve this goal and scripted postfunction like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager.class)
if (projectRoleManager.getProjectRoles(issue.getReporter(), issue.getProjectObject()).any {it.name = "Testers"}){
issue.setAssignee(issue.getReporter())
}
Niranjan
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.
August 12, 2018

Hi @Mark Markov ,

 Thanks for your response. The script throws an error

 Cannot set read-only property: name

Any thoughts? Thanks

 

 

Regards

Niran

Mark Markov
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.
August 15, 2018

Try this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager.class)
if (projectRoleManager.getProjectRoles(issue.getReporter(), issue.getProjectObject()).any {it.name == "Testers"}){
issue.setAssignee(issue.getReporter())
}
Niranjan
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.
September 25, 2018

Hi @Mark,

Thanks a lot for your response. It worked like a charm. Thanks 

 

Regards

Niran 

0 votes
Alexey Matveev
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.
August 7, 2018

Hello,

You can use the Power Scripts add-on to accomplish this task. 

https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation

There is a 30 days trial period for the plugin.

Your post function would look like this:

if (isUserInRole(currentUser(), project, "Testers"))
assignee = reporter;

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, ace, atlassian community event, donation, girls who code, women in tech, malala fund, plan international, kudos, community badge, badge, atlassian badge, International Women’s month, International Women’s Day, women's month, women's day

10 for Change at Atlassian Community Events

Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!

Join an Atlassian Community Event!
AUG Leaders

Upcoming Apps & Integrations Events