Conditional Formatting of Issue List
Asked by Darryl Lee:

So I have a scheduled job that does a search, and returns the list of issues in:

{{#issues}}

The JQL query sorts by Component, and what we'd love to do is send a weekly email report of issues separated out by Component.

It currently looks like this:

![Screenshot 2023-05-18 at 11.06.09 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/258150i3CD55C096D8D4D56/image-size/large?v=v2&px=999 "Screenshot 2023-05-18 at 11.06.09 AM.png")

And what I'd really like is for all of the **Workday** tickets to be together under a *single* **Workday** header.

I've thought about some check whether {{components}} for an issue the same as the immediately prior issue, and if so, don't display it again; otherwise, display it.

But I think without a way to store a variable while iterating through a list, this isn't really possible.

Help me ~~Obi-Wan~~ [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) and [@John Funk](/t5/user/viewprofilepage/user-id/7148) you're my only hope. (Yeah yeah, May 4th was a few weeks ago.)


Answers:
author: Bill Sheboy
body: Hi [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322)

First thing, I do not have Jira Server, and so cannot test this...

I recently saw from another community post that [smart value, list filtering](https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588) does appear to work with the Server version of automation rules. As you already have the full list in {{issues}} you could try using a list filter for each component section in the email.

Kind regards,  
Bill

comments: author: Darryl Lee
body: Thanks Bill!

So my thinking was that the logic for this would probably be the same from Jira Cloud to Server.

And yes, a list filter seems like the right way, but I keep thinking I need a way to set a variable to keep track of what the "previous" component was, so something like:
> {{#issue}}  
> {{#if(not(equals(**components.name** , **previouscomponent** ))}}  
> \<tr style="vertical-align:baseline"\>\<th colspan="2" style="text-align:left" width="80%" bgcolor="#843abc"\>\<font color="white"\>{{components.name}}\</font\>\</th\>  
> **{{HERE IS WHERE I WOULD NEED TO SET previouscomponent = components.name}}**   
> {{/}}  
> DISPLAY OTHER FIELDS  
> {{/}}


author: Darryl Lee
body: Sigh, this hackery did not work:
> {{#issues}}
>
> {{#if(not(equals(components.name, issues.get(index.minus(1)).components.name)))}}  
> COMPONENT SECTION: {{components.name}}  
> {{/}}
>
> {{/}}

OH duh, I'm \*inside\* of the **#issues** iteration and so there's no way to reference a "global" smart value like **issues.get(index.minus(1))**, is there?

Oh man [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) I feel like this is related to this oldie but goodie:

* [access a created variable's value (from a list), using it in a function...within an iterator](https://community.atlassian.com/t5/Automation-questions/access-a-created-variable-s-value-from-a-list-using-it-in-a/qaq-p/1924608)


author: Bill Sheboy
body: My experimentation/usage indicates once inside of an iterator, scope is quite limited. Specifically, and as you found...once inside an iterator:

* the list itself cannot be referenced, and more generally...
* fields in an issue at a higher scope cannot be referenced
* created variables cannot be referenced

I have seen posts from a few Atlassian staff confirming this limitation.

Why are you trying to access the the "previous" component? Is that to make this listing by component dynamic? If so, that may not be possible yet.


author: Darryl Lee
body: Hi Bill - yep, I wanted the listing to be separated by Components, so there would be a section for Netsuite issues, another section for Workday issues, and so on.

Ah well... just wanted to spitball it. Thanks!


Tags: jira

jira-server