Hi,
This question relates to Jira Misc Workflow Extension.
We have a Service Desk project, and a Jira project for every client. When a code issue is identified via a customer issue in the Service Desk project, we create a linked task in the right Jira project.
Each Jira project has a "Production Support" epic.
What I would like to do, is to set the epic of the Task to this Epic using JMWE. However I would need to find the epic ID within the project (they will all be named the same). Is there a way to do this in the query?
Thanks,
Philip
So this is the right approach, but if you use the "Test Nunjucks Expression" button, you'll notice it doesn't quite work, because there are a number of errors in your expression:
So the correct expression is:
{{ ("project=" + issue.fields.project.key + " AND 'Epic Name' IN ('Production Support')")
| searchIssues(maxResults = 1, fields='key')
| first
| field("key") }}
Hi David,
That's excellent, and works well! I had noticed it wasn't working with testing, however was still trying to get my head around the syntax. Slowly getting there now, thanks!
Philip
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Fischer -
I've realised I also need to add a condition to this item, so that the Epic is only set when the item is created from our Service Desk project (otherwise it is being set for every new item created).
I've tried a couple of variations to the Nunjucks template in the condition, based on examples in the documentation. However, they both always return false, so there must be something wrong. Any idea on how to fix? Also, is there a good way to test these, e.g. by running specific components of the logic?
Attempt 1:
{{ issue.fields["Linked Issues"]
| first
| field("project.key") == "HD"
}}
Attempt 2:
{% set items = issue.fields["Linked Issues"] %}
{% set trigger = false %}
{% for item in items %}
{% if item.fields.project.key == "HD" %}
{% set trigger = true %}
{% endif %}
{% endfor %}
{{ trigger }}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Philip,
how are you setting the Epic field? In a Set Field Value post-function put on the Create transition of the customer task workflow?
I assume that task is linked to the JSD issue through a specific link type, right? Let's say that link type (from task to JSD request) is "comes from". Then the conditional execution code would be something like:
{{ issue | linkedIssues("comes from") | first | field("fields.project.key") == "HD" }}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That works, thanks David. I guess now that with my "issue.fields["Linked Issues"]" I was getting a list of IDs, rather than the objects themselves that your query is doing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, issue.fields["Linked Issues"] returns an array of issue links - you can see the whole structure using the dump filter:
{{ issue.fields.issuelinks | dump(2)}}
As you'll see, the linked issues are present but with only a very limited list of fields, and the project field is not one of them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From my reading, it feels like something like the below would work for the Post-Function Set Field Value, EpicLink, but my syntax must be off as it isn't working.
{{ ("project=" + issue.fields.project.key + " AND EpicName IN ('Production Support') | searchIssues(maxResults = 1, fields='key') }}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Philip,
from this example, I assume you're on Jira Cloud, correct?
In which post-function are you trying to set the Epic Link field? Create Issue (while creating the linked task) or some other post-function?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
That's right, on Jira cloud. And it was in the Create Issue post function.
Thanks,
Philip
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.