Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

query that compare field based on a link

fperez September 24, 2020

Hi everyone , 

 

I'm trying to build a JQL that allow me to compare a field between some "causes / is caused by" linked issue. 

The goal is:  

I can use script runner

I got a ticket named Impact into a specific project, link with some other epic tickets in differen other project by "causes / is caused by" link. 

I want to compare the product field and see ticket if the product field is different between linked issue. 

I try many option but i never get something that match the prerequisite.  

2 answers

0 votes
fperez September 24, 2020

Ok JQL seems not what i want (or i can't find the solution in JQL) 

So now i'm tryin to do it in console script 

(actually i just have the process idea )  

projectKey= ...
linkTypeID= ...
customFieldId = ...

Iterate on all issue of $projectKey{

if (projectKeyIssue.link)
print table with projectKeyIssue .name / .link / .customfieldId.value

iterate the linkedIssue

if(projectKeyIssue.customFieldId.value!= linkedIssue.customFieldId.value)

print table with linkedIssue .name / .link / .customfieldId.value

 If someone has ever try to do something like that or have some snippets i can use i'm very interrested !  

Meanwhile i'll try by myself  !  

 

My Thanks in advance 

Gustavo Félix
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2020

Hi @fperez  
Did you figure it out? I was going to answer before but this question got lost on my browser tabs.

fperez September 28, 2020

 

Hi @Gustavo Félix , i'm still trying to find the solution!  

Gustavo Félix
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 28, 2020

@fperez 
You can try to run this first, just to see if this is what you need 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.query.Query
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.IssueLink
import com.atlassian.jira.issue.IssueManager

def projectKey = "TEST"
def linkType = "Relates"
def customFieldName = "test"

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(customFieldName)

//JQL to run
def queryJql = "project = "+projectKey

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def searchResult = ComponentAccessor.getComponent(SearchService).search(user,queryJql,PagerFilter.getUnlimitedFilter())

//It should log the total results after running the jql
log.warn searchResult.total

//This will iterate all the results in your jql . issueTemp is each issue result.
//It will search for every linked issue type. Just to see if it's working.

searchResult.getResults().each{ issueTemp ->
List<IssueLink> allInIssueLink = ComponentAccessor.getIssueLinkManager().getInwardLinks(issueTemp.getId())
def linkedIssue
def parentCustom = issueTemp.getCustomFieldValue(customField)
for(Iterator<IssueLink> inIterator = allInIssueLink.iterator();
inIterator.hasNext();){
IssueLink issueLink = (IssueLink) inIterator.next();
linkedIssue = issueLink.getSourceObject()
def childCustom = linkedIssue.getCustomFieldValue(customField)
if(parentCustom==childCustom){
log.warn issueLink.getIssueLinkType().getName() + "-" + linkedIssue.getKey()
}
}
}

0 votes
fperez September 24, 2020

Hey, still looking for the solution : 

i tryed something like that : 

(issueFunction in linkedIssuesOf("issue=RDVAD-896") AND type = Epic ) OR (issue = "RDVAD-896" AND type = Impact) 

but i would like some automatisation , not having to put the issue and do this for all the isse of a projet AND showing just the issue where field of the issue don't match with the same field of the linked issue. 

It should be easy but it seems not to be ... 

Still open to solution with scritrunner too 

Suggest an answer

Log in or Sign up to answer