Forums

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

Retrieve the last linked issue with max key in jira automation

Anna
Contributor
February 11, 2025 edited

Hi there,

 

I am trying to calculate number of linked issues by using variable with formula and it returns 2 as expected and also need to work with the last linked issue with max key. Here is my variable formula to count all linked issues (minus(1) is used as array starts with index = 0 so for 2 elements the last index will be count of 2 minus 1) 

{{triggerissue.issuelinks.size.minus(1)}}

 

Then I try to retrieve the last element from the linked issues which will be the one with max key and getting the error during calculation. The hardcoded value works fine but the dynamically calculated one returns the error

1. This one returns me expected issue key when index is hardcoded as 1 - {{triggerissue.issuelinks.get(1).inwardIssue.key}}

2. These 2 variations give me error when index calculated dynamically - {{triggerissue.issuelinks.get({{triggerissue.issuelinks.size.minus(1)}}).inwardIssue.key}}

or

triggerissue.issuelinks.get({{triggerissue.issuelinks.size.minus(1).asNumber: lastIssue = {{triggerissue.issuelinks.get({{triggerissue.issuelinks.size.minus(1).asNumber}}).inwardIssue.key}}
Any idea what is missing in dynamic calculation?
Here is the error log:
Error rendering smart-values when executing this rule:
Failed to get value for triggerissue.issuelinks.get({{triggerissue.issuelinks.size.minus(1).asNumber: lastIssue = {{triggerissue.issuelinks.get({{triggerissue.issuelinks.size.minus(1).asNumber}}).inwardIssue.key}}

 


Error rendering smart-values when executing this rule:
Failed to get value for triggerissue.issuelinks.get({{triggerissue.issuelinks.size.minus(1): lastIssue = {{triggerissue.issuelinks.get({{triggerissue.issuelinks.size.minus(1)}}).inwardIssue.key}}

1 answer

0 votes
Anna
Contributor
February 19, 2025

I found the right syntax for the last key.

Last element will be retrieved here

{{triggerissue.issuelinks.last.inwardIssue.key}}

the first element can retrieved as

{{triggerissue.issuelinks.first.inwardIssue.key}}

or 

{{triggerissue.issuelinks.get(0).inwardIssue.key}}

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events