Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,298
Community Members
 
Community Events
184
Community Groups

How to find specific related issue using Groovy scripting in Post Function

Hi there, 

I need to set a specific value on a custom field within some linked issues but not all of them. 

I'm using the 'Set field value of related issues (JMWE app)' Post Function and am using the 'Issues Returned by the following Groovy script' option to find the specific related issues that I require updated. 

From the research I've carried out to date the following syntax returns a list of all of the related issues 

issue.getLinkedIssues()

And these are the results:

Result type:
ArrayList
Result value:
[Test-250, Test-249]

So this gives me all the related links which is great but I need to break that down further and only have the 'Result Value = Test-249' and not just list all of the related issues. 

Is this doable? Does anyone have the correct syntax to use in this scenario? 

Any help appreciated... 

Thanks

 

2 answers

Hi,

That's an old subject but I have a very similar question to this, and cannot find the answer.

I would like to use the same post function, but to retrieve issues with a given set of link types. In the above answer, I tried to replace "issuetype" by variants of "issuelinktype", without success. Does anyone know how to do this ?

Thanks

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 18, 2023

@David Maurel 

why would you even need to use a Groovy script for that? You can simply use one Set field value of related issues (JMWE app) post-function per link type.

But if you really want to use a single post-function, and use the 'Issues Returned by the following Groovy script' option, the script could be:

issue.getLinkedIssues("link type direction name 1") + issue.getLinkedIssues("link type direction name 2") + issue.getLinkedIssues("link type direction name 3")

Note that you need to use link direction name (e.g. "blocks" or "is blocked by") and not the link type name ("Blocks")

Thanks @David Fischer _Appfire_ , I didn't think I could add the issues simply with the operator "+". As for the reason to do this, Here is a screenshot of the actual post-function implemented with another plug-in that you will surely recognize, and which I want to rewrite with JMWE. screenshot_20230119-01.jpg

Several link types (but not all), several fields updated, all in a single post-function. The JMWE "Set field value" allows to set value for only one field. If I had to rewrite this specifying only one link type, I would have to add (number of link types)x(number of fields to be updated) post-functions !

JMWE has multiple benefits compared to the other plug-in, but the ability to set value for multiple fields at once is clearly missing.

Regards,

David

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 19, 2023

Hi David,

Thanks for the clarification. 

You can use the + operator between lists and arrays, which is what getLinkedIssues returns. 

As for a Set Issue Fields post function, it already exists in JMWE for Jira Cloud and will be coming to Jira server soon. 

Thanks. Actually we ARE migrating to Cloud, our Go Live is in 18 days. In our Server instance, we used JWT until now, but I wanted to change so we purchased a license for JMWE Cloud. Instead of rewriting all post-functions with JMWE after the migration, I reckoned that I could do the rewriting in our Server instance, before the migration (thus using a trial license of JMWE Server), and then use the JMWE migration path.

When the migration is complete, I will take the time to "factorize" my multiple set single field value post-functions into one.

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 19, 2023

Be careful though, because of major architecture differences between Jira Server and Jira Cloud, JMWE is also fairly different and, in particular, all scripts will need to be rewritten during the migration. Check https://appfire.atlassian.net/l/cp/zx4pjeCU for details.

That is bad news indeed. I didn't clearly understand that Groovy was dismissed, and 80% at least of my post-functions have Groovy expressions... I guess it's better to have them migrated and having to change the expressions afterwards, than having to recreate all post-functions, since I only have a week-end to do that. Fortunately lots of them have simple expressions like constants or things like issue.get("assignee").

Do you know any converter from Groovy expressions to Nunjucks or Jira expressions ? Or tips to do it more easily than having to learn these languages from scratch ?

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 19, 2023

Unfortunately there is no converter, and the languages are very different. But Nunjucks is actually fairly simple, and JMWE does help you identify what needs to be updated once on Cloud

0 votes
David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 11, 2020

What is your criteria for filtering the linked issues? How do you decide which linked issues should be updated?

Hi David, 

The linked Issues are all using the same Link Type so I'm thinking that the best way of filtering the issues so that I just update the one I need to is via the 'Issue Type' name...

Is that feasible? 

 

Rgds,
Vivienne

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 17, 2020

Hi Vivienne,

sure, you could do something like:

issue.getLinkedIssues()?.findAll{it.get("issuetype")?.name in ["Bug","Task"]}

to return all linked issues of type Bug or Task.

Hi David, 

That worked... 

Thank you so much for the help on this... appreciate it. 

Rgds,
Vivienne

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events