Error in Validator script to check all the linked issues should have status "Verified"

shivaram March 17, 2020

I have this code

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
import org.apache.log4j.Category
import com.atlassian.jira.issue.link.IssueLink
import com.opensymphony.workflow.InvalidInputException

IssueLinkManager linkMgr = ComponentAccessor.getIssueLinkManager()

for (IssueLink link in linkMgr.getOutwardLinks(issue.id)) {

log.debug("linked issue type: " + link.issueLinkType.name)
log.debug("linked issue key: " + link.getSourceObject().getKey())
log.debug("linked issue status (name): " + link.getSourceObject().getStatus().getName())
log.debug("linked issue status (id): " + link.getSourceObject().getStatus().getId())

if (!link.getSourceObject().getStatus().getName().contains("Verified")) {
log.debug("issue " + link.getSourceObject().getKey() + " is not in Active state")
invalidInputException = new InvalidInputException("Linked issue is not in a status of Template")
throw invalidInputException
}
}

 

here,.. it should check all the linked issues are in verified state and then change the status of the issue.

All i get is invalid error exception : null.

 

could anyone please help???/

2 answers

1 accepted

0 votes
Answer accepted
sukkeong
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.
March 17, 2020

I am guessing the exception trace shows the exception is occurring in the for loop condition. (It is a good idea to get the stack trace whenever an exception occurs because it helps with debugging)

You could try this instead as your for loop condition

for(linkMgr.getLinkCollectionOverrideSecurity(<issuekey>).getAllIssues()) 
0 votes
Aditya Sastry
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.
March 19, 2020

Hey shivaram,

Try the below code in your validator

int count=issue.getLinkedIssues("Includes").size()
int status
issue.getLinkedIssues('Includes').each{
if(it.getStatus().getName()="Verified")
{status++}

}
if(count==0||count==status){
return true}

else{return false}

I hope this is what your are looking for.

junxian diao December 8, 2020

@Aditya Sastry 

where the issue from?

Suggest an answer

Log in or Sign up to answer