Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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.bc.issue.search.SearchService
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
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

273 views 3 20
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