It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Angela Tran Oct 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 [Innovalog] Oct 26, 2016

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

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

Thank you! It works. 

Jeanne Howe Community Leader Nov 07, 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 [Innovalog] Nov 07, 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 Community Leader Nov 08, 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 [Innovalog] Nov 08, 2016

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

Jeanne Howe Community Leader Nov 09, 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 [Innovalog] Nov 09, 2016

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

Jeanne Howe Community Leader Nov 09, 2016

Nope, nothing in the logs at all

Jeanne Howe Community Leader Nov 09, 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 [Innovalog] Nov 09, 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 Community Leader Nov 09, 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 [Innovalog] Nov 09, 2016

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

Jeanne Howe Community Leader Nov 09, 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 Community Leader Nov 09, 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 Community Leader Nov 09, 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 [Innovalog] Nov 09, 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
David [Innovalog] Oct 26, 2016

Are you running JMWE on JIRA Server or JIRA Coud?

0 votes
Angela Tran Oct 26, 2016

server

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar invitation: Generate custom Jira Cloud PDF reports and exports

Jira may be a staple part of your workday, but your colleagues, customers, business partners or an auditor might need information presented in a different format, that is easy to access and read. And...

60 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you