Hello,
I am seeking assistance with a specific use case in Jira Cloud using JMWE. Here's what I'm trying to achieve:
However, I'm facing challenges in setting up a conditional execution script in JMWE
I would really appreciate any guidance or suggestions to resolve this.
Thank you for your assistance!
Hi @Ahmed Saci
for that you'll need to add a "Sequence of Post-functions" post function to the Create transition of the Story workflow. In that Sequence, you'll then add 2 post functions:
First, a "Set Issue Fields" post function to set the "Epic Link" field to this value:
{{("type = Epic and project = " + issue.fields.project.key + ' and summary ~ "\\\"' + issue.fields["my custom field"] + '\\\"" ') | searchIssues(fields="key") | field("key")}}
where you'll replace "my custom field" with the custom field name or ID.
Second, a Create Issue post-function where the issue type is Epic, the Summary is:
{{issue.fields["my custom field"]}}
and Conditional Execution is:
{{issue.fields.parent.key}}
Note that this will only work if the custom field "my custom field" doesn't contain special characters - this is a limitation of Jira's JQL search for the Summary field, which only supports the ~ operator.
Hello @David Fischer ,
Thank you for your prompt response and detailed instructions. I've followed the steps you provided, but I'm encountering some issues.
Firstly, although the task is created as expected, the linkage between the task and the epic doesn't seem to be working correctly. Moreover, when the epic doesn't exist, the system isn't creating a new epic with the name from the custom field filled out by the client upon request.
Here's the workflow I aim to establish:
issue (task) Creation: When a ticket is created, there's a custom field filled out that specifies a particular name.
Epic Check and Creation: I want the system to check if an epic with the same name (as specified in that custom field) already exists.
1-If the epic exists, the new issue (Task) should be linked to that existing epic.
2-If the epic does not exist, a new epic should be created with the name from the custom field. This should happen immediately after the issue creation.
Ticket-Epic Linkage: Subsequent
to the check and potential epic creation, the issue should then be linked to the epic (whether it was pre-existing or newly created).
I've followed the instructions you provided and set it up exactly as you suggested. Please see the attached screenshot for reference. Unfortunately, it's not working as expected
Could you assist me in resolving these challenges? Any further help would be greatly appreciated.
Thank you in advance for your support.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ahmed Saci
first of all, you need to put these two post functions inside a "Sequence of post-functions" post-function (yes, it's the name of a post function in the list of post functions you can add to a transition), and then add the Set Issue Fields and Create Issue(s) post functions inside the "Sequence of post-functions" post-function. You also need to reorder the two post functions to make sure the "Create Issue(s)" post function is on top.
Then, in the Create Issue(s) post function, assuming 10109 is the field ID of your single-line text field, the value of the summary field should be:
{{issue.fields.customfield_10109}}
Also, the conditional execution code I provided was incorrect, here is the correct code:
{{("type = Epic and project = " + issue.fields.project.key + ' and summary ~ "\\\"' + issue.fields["my custom field"] + '\\\"" ') | searchIssues(fields="key") | field("key")}}
Finally, don't select any link type option (don't create a link between the current issue and the new Epic)
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 ,
Thank you for your guidance earlier. I tried implementing your suggestions, but I'm still facing issues.
Firstly, I'd like to clarify that the field issue.fields.customfield_10109 is a dropdown list. Therefore, I'm using issue.fields.customfield_10109.value to fetch its value, else it returns an object.
Now, coming to the main concern: The condition in the "Create Issue" post-function. My objective is to ensure that an Epic is created only if an Epic with a specific criteria doesn't already exist in the project. If such an Epic is found, then the "Create Issue" function shouldn't create a new one; if not, then it should create a new Epic.
The primary challenge I'm facing is with the condition in the "Create Issue" post-function. I need a condition that checks the existence of the Epic based on the criteria, not its parent link or anything else.
Following this, in the "Set issue fields" post-function, I aim to update the "Epic Link" to associate the task either with the newly created Epic or with the existing one.
Could you please guide me step-by-step, especially regarding this condition? Your assistance will be greatly appreciated.
Thank you so much.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ahmed Saci
first of all, on the Create Issue(s) post-function, you're missing the conditional execution code:
{{ (("type = Epic and project = " + issue.fields.project.key + ' and summary ~ "\\\"' + issue.fields.customfield_10109.value + '\\\"" ') | searchIssues(fields="key") | field("key")) == ""}}
As for the value of the Epic Link field, it should be:
{{ ("type = Epic and project = " + issue.fields.project.key + ' and summary ~ "\\\"' + issue.fields.customfield_10109.value + '\\\"" ') | searchIssues(fields="key") | field("key")}}
Let me know if that works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much for your assistance. It's working perfectly now.
I truly appreciate your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ahmed Saci
I'm glad it works.
Can you please "accept" the answer so that other users can find it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.