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, jira product discovery, jpd premium, product management, idea management, product discovery, jira premium, product planning, atlassian community, product development, roadmap planning, product prioritization, feature management

Introducing Jira Product Discovery Premium ✨

Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.

Learn more
AUG Leaders

Atlassian Community Events