Forums

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

{{^last}} not working in this code. Any idea why?

Troy Anderson
Contributor
August 21, 2025

Both of these are still printing a comma (, ) at the end of the list.  Any idea why??2025-08-21 18_38_39-Clipboard.png

3 answers

2 accepted

1 vote
Answer accepted
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.
August 22, 2025

Hi @Troy Anderson 

Yes, and...to the suggestions from @Tuncay Senturk _Snapbytes_ with some adjustments...

For iteration which has filtering, I recommend not worrying about a trailing delimiter such as a comma; the complexity / risk of errors is not worth the trouble.

Instead, always add the delimiter and remove it later with text functions prior to a splitting back into a list.  Also, I recommend combining your iterators and conditional filtering.  For example:

  • action: create variable
    • name: varFilteredList
    • smart value:
{{#lookupIssues.issuelinks}}{{#if(and(equals(type.inward, "is cloned by"), inwardIssue.key.startsWith("SCR")))}}{{key}} - {{status.name}},{{/}}{{/}}
  • action: something that needs the list of values
{{varFilteredList.substringBeforeLast(",").split(",")}}

Given the number of filters, it may be better to just change the JQL for the lookup action to avoid this complexity. 

 

Finally, please note: once inside of a {{lookupIssues}} iterator, the issue prefix is not used, just the field smart values.

 

Kind regards,
Bill

Troy Anderson
Contributor
August 27, 2025

Thanks for the tips and suggestions @Bill Sheboy.  

Ultimately, this is all going into a single API call to update/overwrite a Confluence page using values from each entry in #lookupIssues and each item's corresponding #issuelinks.  I am hamstrung in use of a variable in this situation.  There is also no way to group in this manner using standard JQL.
2025-08-27 14_51_23-Clipboard.png

Interestingly, I have needed to use the issue prefix.  The following will filter to the 'correct' linked items but will only write a "-" to the log unless I use issue.key and issue.status.name.  As well, if I use just "key.startsWith", the conditional returns no items.
 2025-08-27 14_44_17-Clipboard.png

The following does write the key and status to the log (without use of the issue prefix), however: 
2025-08-27 14_47_11-Clipboard.png
~edited to add the correct screenshot here.

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.
August 27, 2025

I wonder...

For a given work item, can you write a JQL expression to return the correct work items, and use that to gather them with Lookup Work Items?  Perhaps using the linkedIssues() function:

project = SCR
AND issue IN linkedIssues("{{triggerIssue.key}}", "is cloned by")
ORDER BY key ASC

...adding whatever you need to the JQL.  You may need to invert the link type to get the direction you want.  And, the project may need multiple-project (or global) scope if they are in different projects because now the actual work items are found rather than just the data from the issuelinks smart value.

That eliminates the need for the list filtering causing complications.

Troy Anderson
Contributor
August 28, 2025

I was testing something similar (see below), but I do not know of a way to access more than one set of work items in subsequent actions.  I guess a variable would help with that.  I am not sure I could get the grouping right.

Additionally, I am doing a batch run to keep the page updated with a full set of the latest data.  No specific triggering action, in other words.  I may have to rethink the approach to do exactly what I want to do though.

2025-08-28 10_33_29-Clipboard.png

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.
August 28, 2025

@Troy Anderson -- I was suggesting to change the JQL for the lookup action. 

The linkedIssues() function cannot be used inside of a smart value iterator as it is for JQL.

1 vote
Answer accepted
Tuncay Senturk _Snapbytes_
Community Champion
August 22, 2025

Hi @Troy Anderson 

 

{{^last}} is evaluated against the original loop, not your filtered output.
Because you’re skipping items inside the loop with #if(...), the item you print last usually isn’t the actual last element of the collection. so {{^last}} is still true and you get a trailing comma.

Fix it by making the loop only contain the items you’ll print, then last will work

I am not sure if this will work but you can try something similar below

{{#issue.issuelinks.whereEquals("type.inward","is cloned by")
.whereStartsWith("issue.key","SCR")}}
{{issue.key}} - {{issue.status.name}}{{^last}}, {{/last}}
{{/issue.issuelinks.whereEquals("type.inward","is cloned by")
.whereStartsWith("issue.key","SCR")}}

Troy Anderson
Contributor
August 27, 2025

Thanks @Tuncay Senturk _Snapbytes_.  I understand the reason now. 

I was not able to get your sample snippet to work.  Not finding whereEquals or whereStartsWith as available options.  It does not error, though, which is interesting.  

0 votes
Troy Anderson
Contributor
August 28, 2025

And now I cannot recreate the issue.  REALLY confused...
2025-08-28 17_14_51-Clipboard.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events