I have an Issue Picker custom field.
As part of a Post Function scriptrunner Groovy script i'm wanting to check if any of the issues within the Issue Picker have a specific field value, matching the same field from the parent issue.
The field is an Insight / Asset object field and i only need to return a true or false to determine if other actions are required.
My first thought is to dynamically create a JQL, validate and return to check if it has any values.
Key = ${ParentIssueKey} and issueFunction in issuePickerField('Problem Fixes', 'Source = ${ParentIssueSource}')
In your description, you mentioned:-
I have an Issue Picker custom field.
As part of a Post Function scriptrunner Groovy script i'm wanting to check if any of the issues within the Issue Picker have a specific field value, matching the same field from the parent issue.
The field is an Insight / Asset object field and i only need to return a true or false to determine if other actions are required.
Based on what condition do you want to check if the issues in the Issue Picker have the same value as the Asset field? Is it based on the issues that have been selected from the Issue picker?
Please clarify.
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_
Imagine the Issue Picker has 3 issues selected.
I'd like to determine which of those three issues have specified value in a custom field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For your requirement, you could try something like this:-
import com.adaptavist.hapi.jira.issues.Issues
import com.atlassian.jira.issue.Issue
def assetsValue = issue.getCustomFieldValue('Assets') as String
def samplePicker = issue.getCustomFieldValue('Sample Picker') as List<Issue>
def result = false
samplePicker.each {
def selectedIssues = Issues.getByKey(it.key)
def cpu = selectedIssues.getCustomFieldValue('CPU')
if(assetsValue.contains(cpu)) {
result = true
}
}
log.warn "======>>>> ${result}"
Please note that the sample working code is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Post-Function configuration:-
This code will read the values from the Asset / Insight field and compare it against the value of the CPU field, i.e. from the Issue(s) selected in the Issue picker and check if the Asset field contains the value of the CPU field. If yes, the result returned will be true; otherwise, the result will be false.
Below is a screenshot of the Assets used:-
Below are some screenshots of the CPU text field from the Issues in the Issue Picker:-
Below is a screenshot of the issue comparison between the Assets field and the Issue Pickers:-
So, once the transition takes place if the Issues selected from the Issue picker contain the value of the CPU field that matches the Asset selected, the result returned will be true it will be false as shown in the screenshot below:-
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Has your question been answered?
If yes, please accept the answer else please let me know.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please confirm if your question has been answered.
If yes, please accept the answer.
Else, let me know if I have missed out anything and I will try to update the example.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.