Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Validator to check atleast one linked issue is unresolved

Kishore Kumar Gangavath August 5, 2022

I would like to validate during the workflow transition that atleast one linked issue should be unresolved to move to next status. I am trying with Jira expressions but unfortunately it's not working.

 

3 answers

1 accepted

2 votes
Answer accepted
Kishore Kumar Gangavath August 5, 2022

I used Jira Expressions to validate it and it worked.

issue.links.filter(L => (L.linkedIssue.resolution == null)).length > 0
1 vote
Mark Segall
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 5, 2022

Hi @Kishore Kumar Gangavath -  You cannot set validations on linked behavior, but you can use a field to capture the state of linked activity and use automation to set the field accordingly.  Then set the validator against that field.

0 votes
padraik
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.
August 5, 2022 edited

Making sure I understand, you want the validator to check every issue linked to the issue you are trying to transition, and only allow if if at least one of those issues are unresolved.

With scriptrunner, you can get all linked issues, step through them, and validate whether it has unresolved linked issues with something like the following as a scripted validator in the workflow transition:

 

import com.atlassian.jira.component.ComponentAcessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue

def linkMgr = ComponentAccessor.issueLinkManager

def incomingLinks = linkMgr.getInwardLinks(issue.id)
def outgoingLinks = linkMgr.getOutwardLinks(issue.id)

// This is the flag for an unresolved linked issue
def hasUnresolvedLinkedIssue = false


// Links can be incoming or outgoing
// first we'll step through your incoming links
incomingLinks.each
{
// This is the issue your transitioning issue is linked to
def linkedIssueObj = (MutableIssue) it.sourceObject

// If the linked issue does not have a resolution
if(linkedIssueObj.getResolution() == null)
{
// Set the flag to true
hasUnresolvedLinkedIssue = true
}
}

//This is the same as above, only for your outgoing links
outgoingLinks.each
{
def linkedIssueObj = (MutableIssue) it.destinationObject

if(linkedIssueObj.getResolution() == null)
{
hasUnresolvedLinkedIssue = true
}
}

// If the flag has been set to true, return true, validating the transition
// Otherwise return false and prevent the transition

if(hasUnresolvedLinkedIssue == true)
{
return true
}
else
{
return false
}

 

Kishore Kumar Gangavath August 5, 2022

If any issue is trying to transition to a X status then for that particular issue needs to have atleast an one linked issue and that issue should not have resolution.

jun lee
Contributor
February 9, 2023 edited

@padraik  

Would you like to give me a script?

I want to set validation condition like

: if liked issue type id is 10609, and link type id is 11100 --> true

: if liked issue type id is not 10609, and link type id is 11100 --> false

: if liked issue type id is 10609, and link type id is not 11100 --> true

: if liked issue type id is  not 10609, and link type id is not 11100 --> true

 

In sum, several types of issues may be connected with several connection types. if there is a issue type 10609, validation rule has to check whether the link type is 11100 or not.

 

Thanks in advance

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, ace, atlassian community event, donation, girls who code, women in tech, malala fund, plan international, kudos, community badge, badge, atlassian badge, International Women’s month, International Women’s Day, women's month, women's day

10 for Change at Atlassian Community Events

Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!

Join an Atlassian Community Event!
AUG Leaders

Upcoming Jira Events