jmwe post-function condition

wangzehong March 11, 2021

There are two issue types in my epic. Now I want to work on the workflow of these two issue types. When all the issue of a certain problem type reach a certain state, the epic workflow will reach a certain state correspondingly. The following is the statement I wrote in the condition of the event after the workflow transformation, but I report an error every time. Can someone help me? Thank you very much

flaglist=[]
length1=issue.epic.stories.size()

for(int j=0;j<=length1;j++){
if(issue.epic.stories[j].issueType.name=="需求任务"){
if(issue.epic.stories[j].status.name=="设计待内审"){
flaglist.add(1)
}else{
flaglist.add(0)
}

}else{
continue;
}
}


length2=flaglist.size()
if(flaglist.contains(0)){
return false;
}else{
return true;
}

 

 

There was an error during the execution of your script against issue SAMPLESS-334

Message:
java.lang.NullPointerException: Cannot get property 'issueType' on null object
Stack:
org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)
org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:190)
org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:46)
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:298)
script_9b747e64a039e346c8f58bcf661f3f26.run(script_9b747e64a039e346c8f58bcf661f3f26.groovy:6)

1 answer

1 accepted

1 vote
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 11, 2021

Hi @wangzehong ,

the error is happening because you're going one index too far in your for loop:

for(int j=0;j<=length1;j++){

should be

for(int j=0;j<length1;j++){

But your code could be much simpler:

issue.epic?.stories?.every {
it.issueType.name != "需求任务" || it.status.name=="设计待内审"
}

 

wangzehong March 11, 2021

I truly appreciate your help。

The first method worked. The second logic is slightly different from what I imagined

Suggest an answer

Log in or Sign up to answer