Query for child issues where something in the 'Details' portion of the issue doesn't match parent

Sofie Palacios August 13, 2024

Exactly like the title mentions... I am trying to query for when a child issue doesn't match certain parts of their parent from the 'Details' section of the issue. 

I do have access to scriptrunner and am totally at a loss. 

Any help would be very appreciated!

1 answer

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 14, 2024

Hi @Sofie Palacios

Please clarify, what field type are you using for the Details? Is it a Multi-Line text field?

And what type of comparison are you trying to make between the parent and child field? Is it for a particular word or multiple lines of text?

I am looking forward to your feedback and clarification.

Thank you and Kind regards,

Ram

Sofie Palacios August 14, 2024

Howdy Ram! 

It is drop down field. I'm not sure if it comes standard for Jira, but as an example... 

What I am trying to see is if the drop down field for the parent is set to 'Cat', I want to see all child issues where their drop down fields don't match their parent (i.e. set to 'Dog' instead). 

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 15, 2024

Hi @Sofie Palacios

So for your requirement, you can easily do a query using the ScriptRunner console.

Below is a sample working code for your reference:-

import com.adaptavist.hapi.jira.issues.Issues

def issue = Issues.getByKey('MOCK-1')
def parentListValue = issue.getCustomFieldValue('Sample List')

def differentOptions = [:]

issue.subTaskObjects.each { subTask ->
def subTaksListValue = subTask.getCustomFieldValue('Sample List')

if (subTaksListValue != parentListValue) {
differentOptions << ["${subTask.key}": "${subTask.getCustomFieldValue('Sample List')}"]
}
}

differentOptions

Please note that the sample working code above is not 100% exact to your environment. Hence, you must make the required modifications.

Below is a screenshot of the sample output:-

console.png

For this use case, I have created a sample Task Issue with a Couple of Sub-Tasks.

Below are the screenshots for your reference:-

1. For the Task Issue the value Option1 has been selected from the Sample List field as shown in the screenshot below:-

test1.png

 

2. Below are the screenshots of the Sub-Tasks:-

test2.png

test3.png

test4.pngtest5.pngtest6.png

In the screenshots above all the Sub-tasks except for Sub-taks MOCK-4 and MOCK-7 have the same value in the single select list as the parent issue.

Hence, only MOCK-4 and MOCK-7 are displayed in the result as expected.

I hope this helps to solve your question. :-)

I am looking forward to your feedback.

Thank you and Kind regards,
Ram

 

 

 

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 27, 2024

Hi @Sofie Palacios

Has your question been answered? If yes, please accept the answer.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer