Forums

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

How get issuetype in linkissue from Groovy(Scriptrunner)?

Alex
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.
November 22, 2023

Hi, atlassian community !

I try add condition in post-function, but my code not worked..
My goal:

Start post -function  "Set Field Value Post Function", if in current issue have "issuelink" ,

and in itat least one issuelink has "issue type"  = test

My code :

def list= issue.getLinkedIssues() //result value :  [TENDER-25937, ATL-2925]
//if in array have issue in issuetype == 'test' -> return true

list.eachWithIndex{ elLinkIss, i ->
if (elLinkIss.issueType.name == "test"){
return true
}
}

Thank you any help!

у.png

 

1 answer

1 accepted

1 vote
Answer accepted
Alex
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.
November 23, 2023

I maked code . I hope this helps.
(
pay attention to Boolean logic)

arrLinkedIssue = issue.getLinkedIssues() //[TENDER-25941, ATL-2925] Result type:ArrayList

issLi = []
def issueManager = ComponentAccessor.issueManager

for(i in arrLinkedIssue) {

issueLinkKey = issueManager.getIssueObject(i.toString())
issType = issueLinkKey.get("issuetype").name
issLi.add(issType)
}
//return issLi [Bug, Task]

if('Bug' in issLi){
return false // The task contains a linked task with the task type "Bug" -> Post-function not start!
}
else{ //The task does not have a link task with the task type "Bug" or there is no link at all (null) -> Post-function is launched!

return true
}

 

Suggest an answer

Log in or Sign up to answer