Link to Trigger issue not working
Asked by Dan Snell:

In taken a look around the previous questions, but not been able to find a fix that works for me.

Im using JSM Cloud.

I have an automation rule with the following;

Every day, create a new issue

Then create a new task if a certain label is present

Link that task to the trigger issue

... this doesnt work.

If I use "Link issue to Most Recently Created Issue" is DOES work. The caveat being, if I then run the rule again (even hours later) then two tasks are created, one links to the new ticket, and one links to the old ticket.


Answers:
author: Trudy Claspill
body: Hello [@Dan Snell](/t5/user/viewprofilepage/user-id/5469606)

What are the details of the Schedule Trigger?

To use the Link To Trigger Issue, there must be an issue actually identified in through the Trigger of the rule. For instance when the trigger is Issue Transitioned, the issue that was transitioned is the Trigger Issue for that rule.

When you use a Scheduled trigger, the only way to have a Trigger issue is if the Scheduled trigger retrieves issues with a JQL. If your Scheduled trigger doesn't include a JQL then there is no "trigger issue".

When you use "most recently created issue" that means the issue most recently created **within the same rule execution**. So each time you run the rule the first issue is created by the rule, and if the branch executes to create the second issue then that would be linked to the first issue created in the same rule execution.

What exactly are you trying to do with the branch? Are you trying to review the Labels added to the issue you first created in the rule, and then take some action based on that? Or are you trying to look at other "Check Sensor Health" issues in the project? Can you walk us through an example of what you are trying to accomplish with some example data?

comments: author: Dan Snell
body: [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) the scheduled trigger is set to create a new "Check Sensor Health" issue every day (mon - fri) at 4am. These are reminders for daily tasks which my team need to accomplish.

The Labels attached to the issue, represent customers who we need to perform these checks against.

So, when the primary Check Sensor Health issue is created. I want Tasks to be created, based on what labels are used, and those tasks are then linked to the primary issue.

I hope that makes sense :)


author: Mikael Sandberg
body: Since the automation is a scheduled one the trigger issue will not work. You would have to break the branch part out to its own automation for it to work. The automation would trigger on issue create and then you can use everything from If: Issue matches JQL and down.

comments: author: Dan Snell
body: Ok, Iwill give that a go. Break it out into two rules. One to create the "Check Sensor Health" issue. A second rule to create the Tasks and link to the primary issue.


author: Dan Snell
body: I tried creating two rules. Rule 1 works, its very basic. Rule 2.. doesnt. No errors or anything in the audit log.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/332908iBA46E9787DADEE48/image-size/large?v=v2&px=999 "image.png")


author: Dan Snell
body: Ok, ive got rule 2 to create the Task now... still not linking.


author: Trudy Claspill
body: That is because at the point you are trying to link the issue it is the trigger issue that is in focus. Using the Create Issue action does not change the focus of the rule to the newly created issue. As the rule is currently written, with the focus still on the trigger issue, change the Link Issue action to link to the Most Recently Created Issue. That will create a link between the trigger issue and the newly created issue.


author: Dan Breyen
body: Hi [@Dan Snell](/t5/user/viewprofilepage/user-id/5469606) would it be possible to attach some screenshots of your Automation? Sometimes the Automation pros around here (I'm not in that bucket yet, but trying) can check out what's going on. Or people like me can try to replicate the issue. I'm pretty sure I used Link to Trigger issue and it works for me.

I'm not doing the create every day part.

Also, have you possibly searched [Atlassian's Jira site](https://jira.atlassian.com/secure/Dashboard.jspa) for possible issues?

Hope that helps.

comments: author: Dan Snell
body: Hi [@Dan Breyen](/t5/user/viewprofilepage/user-id/5086375) thanks for the quick response. There should be a post ive just added with a screenshot. Yup, already taken a look around community posts etc. Tried several options, but nothing seems to work.


author: Dan Snell
body: Here is the automation rule (I couldnt add it to the main post for some reason)

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/332895iABB97725F6243365/image-size/large?v=v2&px=999 "image.png")

comments: author: Dan Breyen
body: you read my mind!


Tags: cloud

jira-service-management

jira-service-management-cloud