Forums

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

Transition Linked Issues Post-Function -- How to add a condition that checks the linked issue's project name

Angela Tran
Contributor
October 26, 2016

I am using this plugin to transition linked issues when the link type is fixed by, but I only want the post-function to execute when the linked issue is in a certain project. I want to add this in the condition section. How can I achieve this? 

3 answers

1 accepted

0 votes
Answer accepted
David _old account_
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.
October 26, 2016

You can try the following (untest) Groovy condition script:

linkedIssue.get("project").getKey() == "<project key>"
Angela Tran
Contributor
October 26, 2016

Thank you! It works. 

Jeanne Howe
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 7, 2016

David,

Can this be extended to be project or project category specific?

 

For example, something like this:

If project in A, or B, or C

Then
linkedIssue.get("project").getKey() == "<project key>"
Or maybe something like this:
project category = X
Then
linkedIssue.get("project").getKey() == "<project key>"
David _old account_
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 7, 2016

For multiple projects, you can do something like:

linkedIssue.get("project").getKey() == "A" || linkedIssue.get("project").getKey() == "B" || linkedIssue.get("project").getKey() == "C"

And for a project category:

linkedIssue.get("project").getProjectCategoryObject().getName() == "&lt;project category name&gt;"
Jeanne Howe
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 8, 2016

David,

I modified the code a little.  I want to ensure the current issue is in project category "Learn" and the linked issue is in project CS.

I was able to get the first half of the conditional statement working, but have not been able to get the linked issue to transition.

 

I think I am looking for something like this

issue.get("project").getProjectCategoryObject().getName() == "Learn" &amp;&amp; linkedIssue.get("project").getKey() == "CS"

 

Each condition works on it's own, but when I try to concatenate the two statements, the linked issue does not transition

David _old account_
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 8, 2016

And yet the condition seems to be correct. Are you sure you can reach the two conditions at the same time? 

Jeanne Howe
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 9, 2016

I modified the post function to test each part of the expression

 

When I set the expression to just this:

issue.get("project").getProjectCategoryObject().getName() == "Learn Tech"

the linked issue is not transitioning as expected.

 

When I set the expression to just this:

linkedIssue.get("project").getKey() == "CS"

The linked issue transitions as expected.

So there is something in the first expression that is not right. Please note that I have updated my examples to show that my project category has a space in the name.

David _old account_
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 9, 2016

Any error in the logs? (atlassian-jira.log)

Jeanne Howe
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 9, 2016

Nope, nothing in the logs at all

Jeanne Howe
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 9, 2016

I see this when configuring the post function:

"log: a Logger instance that writes into atlassian-jira.log (useful for debugging)"

How do I add log to the expression?

David _old account_
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 9, 2016

You can do something like:

log.error("project category: "+issue.get("project").getProjectCategoryObject().getName());
return issue.get("project").getProjectCategoryObject().getName() == "Learn Tech" &amp;&amp; linkedIssue.get("project").getKey() == "CS"
Jeanne Howe
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 9, 2016

OK, I added the follow statements:

log.error("project category: "+issue.get("project").getProjectCategoryObject().getName());
log.error("linked project:"+linkedIssue.get("project").getKey());
return
issue.get("project").getProjectCategoryObject().getName() == "Learn" &amp;&amp; linkedIssue.get("project").getKey() == "CS"

 

 The values being returned to the log are correct:

project category: Learn Tech
linked project:CS

 

The linked issue is still not being transitioned sad Ugh

David _old account_
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 9, 2016

You left "Learn" instead of "Learn Tech" in your test

Jeanne Howe
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 9, 2016

Sorry just a typo in the response above. The code in JIRA states Learn Tech

log.error("project category: "+issue.get("project").getProjectCategoryObject().getName());
log.error("linked project:"+linkedIssue.get("project").getKey());
return
issue.get("project").getProjectCategoryObject().getName() == "Learn Tech" &amp;&amp; linkedIssue.get("project").getKey() == "CS"
Jeanne Howe
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 9, 2016

Holy Cr@p I found the issue.

My project category had a trailing space in the name!!

Once I edited the project category to remove the training space, the linked issue transitioned as expected.

 

Thank you so much for all your help and patience with this.

Jeanne Howe
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 9, 2016

On the plus side, the post function did exactly what it was supposed to do. Since the project category did not match the groovy expression, the linked issue was not transitioned. smile

David _old account_
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 9, 2016

I'm glad you found your problem! I'm sorry, I should have thought to ask.

If you are satisfied with our product and our support, would you mind providing a quick review for us in the marketplace? [This link| https://marketplace.atlassian.com/plugins/com.innovalog.jmwe.jira-misc-workflow-extensions/cloud/reviews] will take you directly to the reviews page.

Much appreciated!
David

0 votes
Angela Tran
Contributor
October 26, 2016

server

0 votes
David _old account_
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.
October 26, 2016

Are you running JMWE on JIRA Server or JIRA Coud?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events