Hi,
With Jira automation, I'm doing a lookup and I want to use only the first 20 items of the returned JQL. Since JQL does not support something similar to "TOP N", I wanted to use the index property of the lookup.
Note the "if" below:
{{#lookupIssues}}
{{#if(index.lt(20))}}
{{index}} - {{summary}} (by {{assignee.displayName}})
{{/}}
{{/}}
But this doesn't work, without any errors.
The {{index}} part works as expected (in case I remove the condition).
Can I use the index to get the first items of a lookup result?
Hi @Hagay
Short answer: This may not be possible using {{index}} that way, and there is at least one work-around
Longer answer:
Smart value, list filtering appears to only access the issue fields; {{index}} is an attribute of the list, not of any of the issues. And so it cannot be used in the filtering or apparently with functions. If you believe {{index}} should work this way, I suggest submitting a defect to Atlassian Support.
One possible work-around is to store your lookup issues result in a created variable as a text string, split it by a delimiter, and then use match() with a regular expression to find the first 20 items.
For an example, please see below, and adjust the delimiters, as needed, based upon your issue summary contents (i.e. punctuation characters).
{{#lookupIssues}};index:{{index}} - {{summary}} (by {{assignee.displayName}}){{/}}
{{varLookupData.split(";index").match(":((0|[1-9]|1[0-9]) .*)").substringAfter(" - ")}}
Split the text string on ";index" and leave the starting colon, to create a new list. The match() function will then find only items beginning with ":0" through ":19". The final substringAfter removes the index prefix information, leaving only the summary and assignee.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.