Forums

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

Create issue from current issue's most recently created linked issue

Samuel James April 18, 2025

Dear all,

 

I'm creating an automation - 

1. Trigger occurs when the current issue transitions from UAT to SIT (in the project: CRBT).

2. New issue has to be created in the other project: SIT, issuetype: Test

3. Here's the catch: There's already multiple SIT's issues already linked to the current issue through the issue-link-type: 'Demand'.

Now I want to create a single SIT issue, based on the details available in the most recently linked/created SIT issue.

 

I've written an automation with the following steps.

1. Trigger: current issue transitions from UAT to SIT

2. Branching: For linked issues, linktype = Demand

All actions inside Branch - 

3. JQL: to filter-out for all 'SIT' issues.. issues from other projects filtered-out.

4. Lookup issues: issue in LinkedIssues("{{triggerIssue.key}}") AND issueType: Test ORDER BY created Desc. This gives me all the SIT issues 

5. IF: Advance compare values: {{lookupIssues.size > 0}}. inorder to filterout for most recently created SIT issue.

6. Created a new issue: SIT project, Test issuetype.

Now, when this rule is triggered, Lookup option filter-outs for all the SIT issues in the linked issues, but creates multiple new issues, one for each SIT issue brought by the lookup action.

Looks like the condition number 5 fails to filterout for only the last created SIT issue.

 

Can someone advise how this condition be modified to list only for the last created issue.

 

Screenshot 2025-04-18 at 5.13.14 PM.png

2 answers

0 votes
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.
April 18, 2025

Hi @Samuel James 

There are two design problems with your rule: it is branching over all of the linked issues (potentially adding several issues), and the JQL used in the Lookup Issues action does not account for the link type.

 

For a scenario like this, I recommend first writing the JQL you would use to identify that single, SIT issue which was most recently added, with the specific link type.  This could be done with an example issue which would have triggered your rule.

Once that JQL is working, you may use the Lookup Issues action and get the single issue you want.  Then, use a Branch on JQL to just that single issue, and inside the branch, add the Create Issue action to copy to the data from the branched-to issue.

  • trigger: issue transitioned
  • action: lookup issues to find the desired issues
  • advanced compare condition: to conform you got at least one issue in the lookup results
  • branch: on JQL to the correct issue (either the first or last in your lookup, depending on which ORDER BY clause you used)
    • action: create the issue, copying data needed from {{issue}}

 

Kind regards,
Bill

0 votes
Melbrin NGOUILOU_Andemex
Contributor
April 18, 2025

Hi Samuel,

I understand you're trying to make sure that your automation rule only uses the most recently created SIT issue linked via the "Demand" issue link type, and you're currently seeing multiple issues being processed due to the lookup returning more than one result.

You're on the right track with the ORDER BY created DESC in your JQL, but Jira Automation treats the lookupIssues as a list, and unless you explicitly tell it to use only the first one, it will process them all.

What you can do (I've done something similar before in one of my automation)

Use the {{lookupIssues.first}} smart value to only access the first issue returned (i.e., the most recently created one). Anytime you need to access a specific issue while using a lookup, you must specify it.

Here’s how you can adjust your rule:

  1. Keep your Lookup Issues JQL as it is:
    issue in linkedIssues("{{triggerIssue.key}}") AND project = SIT AND issuetype = Test ORDER BY created DESC
          
  2. Add a new Advanced compare condition:
    {{lookupIssues.first.key}} is not empty
          
  3. In your "Create Issue" action, reference only the most recent SIT issue like this:
    • Summary: Copied from {{lookupIssues.first.summary}}
    • Description: Based on SIT issue {{lookupIssues.first.key}}
    • Link issues: Use the key {{lookupIssues.first.key}}

What to Avoid

Do not use a branch on lookupIssues (it is already like a branching so you're using it twice), as that will run the actions for each item in the list. Instead, just reference the first one directly using smart values.

Result

This will ensure that only one new SIT issue is created, and it will be based solely on the most recently created linked SIT issue.

Let me know if this works for you.

Hope this helps,

Melbrin from Paris ;)

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.
April 18, 2025

Hi @Melbrin NGOUILOU_Andemex 

When posting bot / AI-generated content, ensure you disclose the source in your post text.  For more information, please carefully review the community guidelines:

https://community.atlassian.com/forums/custom/page/page-id/rules-of-engagement

Kind regards,
Bill

Melbrin NGOUILOU_Andemex
Contributor
April 22, 2025

Hi Bill, as I mentionned in my message, this is a problem I've encoutered before. I just use AI for writing and structuring the answer but thanks for the tip ;)

Melbrin

Suggest an answer

Log in or Sign up to answer