Forums

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

JMWE Workflow Condition check all linked issues of specific issutype and linktype having field value

Andy Ukasick
Contributor
July 31, 2019

Please help me to figure out how I can configure a JMWE workflow condition to do the following.

Check that all issues of a specific issuetype which are linked with a specific link type, have a specific value in a custom field and ignore any linked issues that may exist which are not of the specific issuetype/link type combination.

Example:  A "Feature" issue should only allow a workflow transition to "Committed" if ALL issues of issuetype "CommitTask" that are linked by the "Is Related to by" link type have the string value of "Fully Committed" in a custom single line text field called "Commitment Level".

If any other issuetypes are linked by the "Is Related to by" Link Type, they should be ignored. 

If any other issuetypes are linked by any Link Type, they should be ignored. 

If any "CommitTask" (the target) issues are linked by a different Link Type (for example "Relates to"), they should be ignored.

Only linked issues of type "CommitTask" which are linked with the "Is Related to by" link type should be evaluated to see if they ALL have the "Fully Committed" string value in their "Commitment Level" field.  If they all do, then the transition should be allowed.  If only some or none have that in their "Commitment Level" field, then the transition should not be allowed (be hidden).

If there are no issues at all that are of the target issuetype/link type combination, then the Transition should not be allowed.

I have figured out how to create Conditions that evaluate some variations on this, such as checking if at least one issue of the target issuetype that is linked by the target link type, has the target value in its field.  But the case above has me stumped.  When it comes to Groovy scripting I'm afraid that I'm about as dumb as a bag of hammers (although in time I hope to change that!). 

Any help would be greatly appreciated!!  :)

@David Fischer 

1 answer

1 accepted

1 vote
Answer accepted
Radhika Vijji _Innovalog_
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.
July 31, 2019

Hi Andy,

Try this:

//If there are no issues at all that are of the target issuetype/link type combination, then the Transition should not be allowed.
if(!issue.getLinkedIssues("Is Related to by") || issue.getLinkedIssues("Is Related to by").findAll{it.issuetype.name == "CommitTask"} == null)
return false;
//linked issues of type "CommitTask" which are linked with the "Is Related to by" link type should be evaluated to see if they ALL have the "Fully Committed" string value in their "Commitment Level" field. If they all do, then the transition should be allowed.
return issue.getLinkedIssues("Is Related to by").findAll{link ->
link.issuetype.name == "CommitTask"}.every{iss ->
iss.getAsString("Commitment Level") == "Fully Committed"}
//Ignore all the other cases and pass
return true;

Regards,

Radhika

David Fischer
Community Champion
August 1, 2019

A couple of corrections:

//If there are no issues at all that are of the target issuetype/link type combination, then the Transition should not be allowed.
if(!issue.getLinkedIssues("Is Related to by")?.any{it.issuetype.name == "CommitTask"})
return false;
//linked issues of type "CommitTask" which are linked with the "Is Related to by" link type should be evaluated to see if they ALL have the "Fully Committed" string value in their "Commitment Level" field. If they all do, then the transition should be allowed.
return issue.getLinkedIssues("Is Related to by").findAll{link ->
link.issuetype.name == "CommitTask"
}.every{iss ->
iss.getAsString("Commitment Level") == "Fully Committed"
}
Andy Ukasick
Contributor
August 1, 2019

Thank you Radhika and David!  I'm going to try this shortly and I'll reply to let you know how it goes. 

I presume that for this I would use the "Scripted (Groovy) Condition (JMWE add-on) " Condition and not the "Linked Issues Condition (JMWE add-on)" Condition.

David Fischer
Community Champion
August 1, 2019

Correct. Although you could also implement the same with 2 "Linked Issues Condition (JMWE add-on)" Conditions - one to force the existence of at least one CommitTask linked through the "Is Related to by" link type, and one to check that they all have the Fully Committed Commitment Level.

Andy Ukasick
Contributor
August 2, 2019

@Radhika Vijji _Innovalog_  @David Fischer 

 

It works perfectly!!  Thank you both so very much!

Suggest an answer

Log in or Sign up to answer