ComponentAccessor.getIssueLinkManager does not return correct counts

Calderara Serge April 25, 2022

Dear all,

I have a wierd issue in by getting the list of related linked to issue.

If I create an issue with 2 relates to linked issue, the following code returns correctly the 2 related issue using

def links =ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId())

return links.size() => return 2 = OK

If then I add a new relates to issue to same parent issue and run the code again,  it is still returning 2 instead of 3.

Any idea what is wrong ?

 

Here is my all custom scripted field code

=>

import com.atlassian.jira.component.ComponentAccessor
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

if (issue.issueType.name == "Service Request") {

def links = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId())

//def links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())


def BudgetField =customFieldManager.getCustomFieldObjects().findByName("Budget Number")
def CurrencyField =customFieldManager.getCustomFieldObjects().findByName("Currency")
def CurencyValue=issue.getCustomFieldValue(CurrencyField)

//return links[0].getSourceObject()


double Budget=0
for( l in links) {

//use this for Outward links
// output = output + l.getSourceObject().issueType.name + "<br/>"
if (l.getSourceObject().getCustomFieldValue(BudgetField) != null){
double val= l.getSourceObject().getCustomFieldValue(BudgetField)

Budget=Budget + val

}
//use this for Inward links
// output = output + l.issueLinkType.name + ": " + l.getSourceObject() + "<br/>"

}

return (Budget + " $CurencyValue")
}

<==

regards

 

 

1 answer

1 accepted

0 votes
Answer accepted
Calderara Serge April 25, 2022

I found out the reason.

The problem was comming from the fact that Jira gets by default same value for InWard and Outward link for Relates entry, which is quite non sense as direction is really important

Regards

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events