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.
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"/)