Forums

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

Jira automation help

Dennis_H
Contributor
March 25, 2021

I'm hoping I can create an automation rule that:

 

when a new subtask (a subtask type specifically created for this)is created it is automatically linked to issues that are in a particular status AND have a particular field set, so for example:

 

Rule is along the lines of when subtask X is created, link to any issues in status "testing" that has the custom field of ready is set to "yes", so if there are 40 issues in status "testing" but only 4 have the ready field set to yes, then it would link the 4 issues.

Add to that if any of the issues in status "testing" are changed after the inital subtask is created, the ready field is set to yes then it would link to the subtask originally created

Might be a tall ask for automation but lets see if it can be done.

 

1 answer

1 vote
Bill Sheboy
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.
March 25, 2021

Hi @Dennis_H 

What have you tried thus far to accomplish this?  If you post an image of the rule you have thus far, and any errors, that will help the community to provided you suggestions.

For some information about example rules and documentation, please look here:


Best regards,

Bill

Dennis_H
Contributor
March 26, 2021

I really don't have a rule formed yet, that what I'm trying to figure out. Can automation be used successfully for this request? It's a bit tricky (to me anyways) and I'm looking for assistance with forming something that will work.

Bill Sheboy
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.
March 26, 2021

Gotcha; I wanted to check if you already have something which to consider. 

Would you also please describe the problem you are trying to solve?  I am wondering if these rules could create conditions of duplicate/unnecessary links when there is already a parent/child relationship between some issues.

The first rule you describe is possible:

  • Trigger: issue created
  • Issue fields condition: issue type is sub-task
  • Branch: on JQL for project = myProject AND status = "Testing" AND "Ready Field" = Yes    For this JQL, you may want to consider if there is other criteria you need, such as issue type.
    • Action: link issue to Trigger Issue (the sub-task).  You need to pick a link type

For the part you describe as "And to that..." for later issue changes which seems a bit unclear to me.  What would change in an issue that would lead you to link it to the already created sub-task?

Dennis_H
Contributor
March 26, 2021

So if I have a subtask with 3 issues already linked to it because the field in the issue was set when the rule ran those would be linked, however if another issues field is set with a certain value I'd like it to link to the issue that matches (the field is set the same), so for example:

 

I have subtask "subtask 1" created and when it was created it checked all of the issues in status "ready" and linked any issues that had a custom field set to "yes" and ignores ones with the custom field set to "no". Now if after the subtask is created I'd like to create a rule that if an issue in status "ready" the custom field is changed to "yes" then it links to the subtask that was previously created

Bill Sheboy
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.
March 26, 2021

Thanks for adding that information.  Here is the challenge you need to address:

When the currently unlinked issue, in a status of "ready", changes its custom field value to "yes"... How does it know to which sub-task to link?

If you are able to answer that question (TBD below) you can create a rule to add the link later:

  • Trigger: field value changes for custom field
  • Condition: custom field value is "Yes"
  • Condition: status is "ready"
  • Branch: TBD select the sub-task
    • Condition: TBD -- is not already linked to the sub-task
    • Action: link to the trigger issue
Dennis_H
Contributor
March 26, 2021

I could create a field specific to the the subtask as there will only be one at a time, so the subtask could have a custom field of "link" and we are able to set a value upon creation. Then if one of the issues in ready has the same field and it's set to the same value as the subtask it could be linked (I think?),

Bill Sheboy
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.
March 26, 2021

That might work; I suggest building the first rule (on sub-task created) and testing it.  Then create the second one to confirm it works as you expect when trying to select back to the sub-task.

Dennis_H
Contributor
March 29, 2021

Is there a way via JQL to compare fields in two different issues? If so I could set a rule that when the "link" value is set, it used JQL to find the matching issue then link to that issue?

Bill Sheboy
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.
March 29, 2021

Not out of the box, as JQL isn't a SQL.  With automation you have additional options:

  • If the comparison value is in the trigger issue, you can reference the smart values in the JQL
  • Or...you could capture the comparison value using Create Variable, and then reference that in the JQL.  This technique helps when the comparison value doesn't come from the trigger issue.
Dennis_H
Contributor
March 29, 2021

I tried the following and the JQL didn't work but the direct reference did

JQL

project = "MY project" and status = Open and "Service type[Dropdown]" = MYservice and issuetype = my-subtask

Gave the following error:

Link issues

Error linking issuesproject = "My Project" and status = Open and "Service type[Dropdown]" = MYservice and issuetype = my-subtask: Issue does not exist or you do not have permission to see it.

But if I just set the issue # instead of the JQL it linked. If I run that query in the filters section it pulls up the correct issue. Not sure about the permissions issue as the creator of the issue is Automation for Jira.

 

If I can get this to work I think it will suit my needs.

Bill Sheboy
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.
March 29, 2021

I am trying to understand the context for that error message.  If this is from JQL in a rule, would you please post an image of the entire rule?  Thanks!

Dennis_H
Contributor
March 29, 2021

Thats the entire rule (with the true names). If I replace the JQL with the specific issue # it links.

Jira11.jpg

Bill Sheboy
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.
March 29, 2021

Thanks for that information. 

Is this rule running in the "DCS Development" project?  If not, rules which impact multiple projects need to be defined an run at a global scope.

Dennis_H
Contributor
March 29, 2021

I have it running just in the DCS Dev project.

Dennis_H
Contributor
March 29, 2021

When I run that exact JQL in the advanced issue search it returns the expected issue as a result. No errors.

Bill Sheboy
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.
March 29, 2021

That is curious... Have you tried to branch on the JQL and then link them, one by one to the trigger issue?

Dennis_H
Contributor
March 29, 2021

Hmm, not sure how that would work.

Bill Sheboy
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.
March 29, 2021

Something like this, with only a small change to your rule:

  • Trigger: when value changes for Service Type
  • Condition: when Service Type equals Bitcoin
  • Branch: on the JQL you noted
    • Action: link issue to trigger Issue

This will link the trigger issue to each issue returned by the JQL in the branch.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events