Hi everyone.
I'm trying to obtain the status and project key of linked issues to create a clone of the main issue but when I'm applying the log the project and status have false value and doesn't have de Project key and status.
following my code.
import org.apache.log4j.Category
def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)
def issuelinkPJ = issueLinkManager.getOutwardLinks(issue.id).any{it.destinationObject.getProjectObject().getKey()}
def ORstatus = issueLinkManager.getOutwardLinks(issue.id).any{it.destinationObject.getStatus().getName()}
if (!issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('is blocked By')) {
if (issuelinkPJ == 'OR' && ORstatus == 'Blocked'){
return true
}
}
Ok I found a rustic way.
It is working.
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
if (link.issueLinkType.name != "is blocked by") {
log.warn("LINK IS NOT - IS BLOCKED BY")
if (link.getSourceObject().getStatus().getName().contains("Blocked")){
log.warn("STATUS BLOCKED")
if(link.getSourceObject().getProjectObject().getKey().contains("OR")){
log.warn("PJ OR = OK")
}
else{
log.warn("IS NOT PJ OR")
}
}
else{
log.warn("STATUS NOT BLOCKED")
if(link.getSourceObject().getProjectObject().getKey().contains("OR")){
okflagfalse = 1
}
}
}
else {
log.warn("LINK == IS BLOCKED BY")
if(link.getSourceObject().getProjectObject().getKey().contains("OR")){
okflagfalse = 1
}
}
}
log.warn("STATUS=" + okflagfalse)
if (okflagfalse == 1) {
return false
}
if (okflagfalse == 0) {
return true
}
Hi Sergio,
Your code is very confusing.
First off, 'any' closure returns a boolean value. Looking at your code both 'issuelinkPJ' and 'ORstatus' variables will have a 'false' value. Then you are trying to compare them, boolean values, with string values ('OR' and 'Blocked'). Naturally it simply doesn't work like this.
Secondly, this line is also wrong:
if (!issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('is blocked By'))
Assuming you want to check if that none of the links in your issue have the name 'is blocked By' then your code should be like this:
if (!issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType*.name.contains('is blocked By'))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just resolved doing it.
Maybe my code is not the optimal but I resolved the problem.
import org.apache.log4j.Category
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)
IssueLinkManager linkMgr = ComponentAccessor.getIssueLinkManager()
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
if (!issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('is blocked By')) {
if (link.getSourceObject().getStatus().getName().contains("Blocked")){
if(link.getSourceObject().getProjectObject().getKey().contains("OR")){
return true
}
else{
log.warn("message")
}
}
else{
log.warn("message")
}
}
else{
log.warn("message")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
mmm I 'm having a logic problem. Because this code is for create only one issue cloned. But when I press the transition button again it is create another ticket.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ivan Tovbin
Thanks for your help.
I need to know if any linked issue have "is Blocked by" relatioship and if the statuas is iqueal to blocked and if the project is equal OR.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.