It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Create new JQL function for Script Runner

DerivcoITServer Feb 08, 2016

Hi,

I am new writing add-ons/plugins for Jira.

Using Script Runner I can perform the following query that returns issues that where last updated by any user part of the Developer role.

issueFunction in lastUpdated("inRole Developers")

I would like to write a similar function that would return me issues where the assign is part of a specific role. Example:

issueFunction in Assignee("inRole Developers")

The documentation that I have found does not give examples on how to do this. Only a template is available.

https://gist.github.com/jechlin/11153983

Would you be able to provide some sample code or more comprehensive documentation on how to achieve this?

I assume it would be something like this, but Im not sure where to put this in the template.
ComponentManager componentManager = ComponentManager.getInstance()
ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager
ProjectRole devRole = projectRoleManager.getProjectRole("Developers")
projectRoleManager.isUserInProjectRole(issue.assignee, devRole, issue.projectObject)

 

Thanks.

1 answer

0 votes
JamieA Feb 08, 2016

I would not call the function Assignee. You could do it your way but it would be slow as it requires retrieving each issue and calling your code on it.

It would be better, although harder, to write a query that ends up as the following query:

(project = X and assignee in (user1, user2, <all Developers of X>) ||
  (project = Y and assignee in (user1, user2, <all Developers of Y>) || 
	... etc, for all visible projects

That looks complex but that will be fast to execute.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Marketplace Apps & Integrations

Demo Den Ep. 4: Continuous Integration with CircleCI & Jira Software

Get ready! Demo Den Episode 4 is coming your way on Tuesday, May 28, 2018 with a Continuous Integration and Delivery special demo. CircleCI Director of Solutions Engineering, Eddie Webb will show us ...

452 views 0 4
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you