Custom Scripted Condition Using Both INward & OUTward Links Failing

I have looked here and here and here. And many other places. I cannot for the life of me figure out why this cannot read EITHER inward OR outward for this condition.

Does not work:

--- if (! issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Reopen') || ! issueLinkManager.getInwardLinks(issue.getId())*.issueLinkType.name.contains('Reopen'))

 

Implemented in lieu:

 

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.link.IssueLinkManager;
import com.atlassian.jira.issue.IssueFieldConstants;
import com.atlassian.jira.issue.fields.IssueLinksSystemField;
import com.opensymphony.workflow.InvalidInputException;
import webwork.action.ActionContext;

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def fields = []

def fieldManager = ComponentAccessor.getFieldManager()
def linksSystemField = fieldManager.getField("issuelinks") as IssueLinksSystemField

def request = ActionContext.getRequest()
if (request) {
    def params = request.getParameterMap()
    def issueLinkingValue = linksSystemField.getRelevantParams(params) as IssueLinksSystemField.IssueLinkingValue

// If issue is not REOPENED LINK TYPE, make all sorts of validations
if (! issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Reopen') ) 
    {
    fields.addAll(['BA Actual Hours', 'BA Analysis By', 'Bug Source', 'Complexity', 'Data Fix', 'Dev Estimate Hrs', 'QA Estimate Hrs', 'RCA Categories - BA', 'Release Notes', 'Stat Code Impact'])

    fields.each 
        {
        CustomField cf = customFieldManager.getCustomFieldObjectByName(it)
        if (cf && !issue.getCustomFieldValue(cf)) 
            {
            if (invalidInputException)
                invalidInputException.addError(cf.id, "Value missing!")
            else
                invalidInputException = new InvalidInputException(cf.id, "Value missing!")
            }
         }       
    if (invalidInputException)
        invalidInputException.addError("The fields marked below must be filled before analysis is completed.")
}
else return true
}

 

And I am sure I have a lot of unnecessary stuff in here. I'm doing the best I can sad

 

WHat I need to know is how do I make this condition pass for EITHER inward OR outward links? If I tell it either/or, then (based on how I wrote the clause) either: everything fails, inward fails, or everything passes regardless of links.

1 answer

1 accepted

This widget could not be displayed.
Change || to &&
"Not outward linked" AND "Not inward linked"
e.g.
Not Red AND Not Blue -> Blue = Fail, Red = Fail, Green = Pass
Not Red OR Not Blue -> Blue = Pass, Red = Pass, Green = Pass
!issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Reopen') && !issueLinkManager.getInwardLinks(issue.getId())*.issueLinkType.name.contains('Reopen'))

I know we don't know each other.

But I love you.

 

THANK YOU!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

165 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you