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?
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"/)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.