Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Scriptrunner - Limit results on issue picker based on current issue organization

Hello all

I need to write a scripted field or behaviour (not quite sure) where I have a Issue Picker Custom Field for a specific project where I need it to behave like described below:

I am working on an specific issue, let´s say, PROJECT-1 and this issue has an organization associated named CLIENT1. This project has a custom field called "Associated Problem" where I must limit the results only to bring other issues from this project that the organization is the same, i.e CLIENT1 and that status are "Open" and "In Progress"

This logic must follow for other issues from this project having other organizations.. CLIENT2... CLIENT3.... etc.
I am able to limit by status using simple JQL but I am quite inexperient on scripting and I am not finding a easy solution for matching only results from same organization as the current issue.

Can you people give me some light into this?

1 answer

1 accepted

For anyone looking for a similar solution, I have managed to work that out.

In short, I have created a Issue Picker Field called "Issue Associada" and on Behaviours I created an new entry associated to this field.

This field will have a dynamic JQL which will look for current issue custom field called "Organização" (not the same as system Organization) and will search for results

My script, although not elegant, is working fine.


import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue;

def customFieldManager = ComponentAccessor.getCustomFieldManager()

//Here I will define variable issuePicker to get Custom Field "Issue Associada"

def issuePicker = getFieldByName("Issue Associada")

//Here I will get Custom Field value from custom field "Organização" and set it on a variable. This value comes from  from the issue I am editing the Issue Picker field.

def Value = customFieldManager.getCustomFieldObjectByName("Organização")
def orgValue = underlyingIssue.getCustomFieldValue(Value)

//Below I am running a query JQL looking for specific conditions including my new variable

issuePicker.setConfigParam('currentJql', /project = "Implantação" and status = "Em Andamento" and Organização = "$orgValue"/)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

How we use Jira Service Management for our recruitment process! - Part 2

It is never about setting up a process and being done with it. Rather, the focus should always be on optimizing it for the best outcomes. Thus, we didn’t stop at setting up JSM for our recruitment pr...

216 views 0 5
Read article

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