Forums

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

Filtering on Scheduled Automation JQL Results

Tom Scoggin
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.
June 23, 2023

I have a scheduled automation that returns the correct list of items. Is there a way now to filter that result for use in an email? Every time I try to do this I get the full list returned and not a filtered list. I'm trying to filter on the Labels field.

Code is below.

{{#issues}}
{{if (equals(issue.labels, "STAGING-APPROVAL"))}}
<ul style="background-color:AntiqueWhite;font-size:18px;">
    <li><strong><a href="{{url}}">{{key}} - {{summary}}</a></strong>
        <ul style="background-color:AntiqueWhite;font-size:18px;">
        <strong><li>Description:</strong> {{description}}</li>
        </ul>
    </li>
</ul>
{{/}}

1 answer

1 accepted

1 vote
Answer accepted
Darryl Lee
Community Champion
June 23, 2023

Ohey @Tom Scoggin - similar to this answer the problem is that when filtering lists (or Atlassian calls it, conditional logic), smart values within the filters are always relative to the list. So this should work:

{{#issues}}
{{#if (equals(labels, "STAGING-APPROVAL"))}}
<ul style="background-color:AntiqueWhite;font-size:18px;">
    <li><strong><a href="{{url}}">{{key}} - {{summary}}</a></strong>
        <ul style="background-color:AntiqueWhite;font-size:18px;">
        <strong><li>Description:</strong> {{description}}</li>
        </ul>
    </li>
</ul>
{{/}}
{{/}}

(Also, you needed a # before the if, and another closing {{/}})

ALTHOUGH now that I think about it, labels is probably a list, so I'm a little concerned if there's more than one label on an issue. Let me go test...

Tom Scoggin
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.
June 23, 2023

@Darryl Lee 

This returned 0 results out of the 17. It should have returned 2. I agree it may be tricky because Labels is a list. Not sure how to maybe do a "Like" for this.

Like Darryl Lee likes this
Mark Segall
Community Champion
June 23, 2023

Further to the answer from @Darryl Lee

I haven't tried myself, but you may be able to do something like this:

{{#issues}}
{{#if (exists(labels.match("(STAGING-APPROVAL)"))}}
<ul style="background-color:AntiqueWhite;font-size:18px;">
    <li><strong><a href="{{url}}">{{key}} - {{summary}}</a></strong>
        <ul style="background-color:AntiqueWhite;font-size:18px;">
        <strong><li>Description:</strong> {{description}}</li>
        </ul>
    </li>
</ul>
{{/}}
{{/}}
 
Like Darryl Lee likes this
Darryl Lee
Community Champion
June 23, 2023

Ah, thanks @Mark Segall - that's not quite right but it got me on the correct path. this works:

{{#issues}}
{{#if (labels.match("(STAGING-APPROVAL)").size.gt(0))}}
<ul style="background-color:AntiqueWhite;font-size:18px;">
<li><strong><a href="{{url}}">{{key}} - {{summary}}</a></strong>
<ul style="background-color:AntiqueWhite;font-size:18px;">
<strong><li>Description:</strong> {{description}}</li>
</ul>
</li>
</ul>
{{/}}
{{/}}

One minor note: My JQL didn't initial include ORDER by key ASC so the issues were just in random order. Adding the ORDER bit cleaned things up.

Have fun!

Like Mark Segall likes this
Tom Scoggin
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.
June 26, 2023

@Darryl Lee @Mark Segall Thank you for the help. This worked.

Is there a way to run through the issues twice? I need to loop through for all the Staging Approvals and then again for all Production Approvals but I can't get the second loop to run.


<p style="background-color:powderblue;font-size:30px;"><strong>CRs Needing Staging Approval</strong> </p>

{{#issues}}

{{#if (labels.match("(STAGING-APPROVAL)").size.gt(0))}}
<ul style="background-color:AntiqueWhite;font-size:18px;">
<li><strong><a href="{{url}}">{{key}} - {{summary}}</a></strong>
<ul style="background-color:AntiqueWhite;font-size:18px;">
<strong><li>Description:</strong> {{description}}</li>
</ul>
</li>
</ul>
{{/}}
{{/}}

<p style="background-color:powderblue;font-size:30px;"><strong>CRs Needing Production Approval</strong> </p>

{{#issues}}

{{#if (labels.match("(PRODUCTION-APPROVAL)").size.gt(0))}}
<ul style="background-color:AntiqueWhite;font-size:18px;">
<li><strong><a href="{{url}}">{{key}} - {{summary}}</a></strong>
<ul style="background-color:AntiqueWhite;font-size:18px;">
<strong><li>Description:</strong> {{description}}</li>
</ul>
</li>
</ul>
{{/}}
{{/}}Capture.PNG

Tom Scoggin
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.
June 26, 2023

This worked as a loop on the {{#issues}}

<p style="color:white;background-color:orange;font-size:30px;">&nbsp;Needs Staging Approval </p>

{{#issues}}

{{#if (labels.match("(STAGING-APPROVAL)").size.gt(0))}}
<ul style="background-color:AntiqueWhite;font-size:18px;">
<li><strong><a href="{{url}}">{{key}} - {{summary}}</a></strong>
<ul style="background-color:AntiqueWhite;font-size:18px;">
<strong><li>Description:</strong> {{description}}</li>
</ul>
</li>
</ul>
{{/}}
{{/}}

<p style="color:white;background-color:Blue;font-size:30px;">&nbsp;Needs Production Approval </p>

{{#issues}}

{{#if (labels.match("(PRODUCTION-APPROVAL)").size.gt(0))}}
<ul style="background-color:AntiqueWhite;font-size:18px;">
<li><strong><a href="{{url}}">{{key}} - {{summary}}</a></strong>
<ul style="background-color:AntiqueWhite;font-size:18px;">
<strong><li>Description:</strong> {{description}}</li>
</ul>
</li>
</ul>
{{/}}
{{/}}

<p style="color:white;background-color:Green;font-size:30px;">&nbsp;Needs REVIEW-For-CLOSURE </p>

{{#issues}}

{{#if (labels.match("(REVIEW-For-CLOSURE)").size.gt(0))}}
<ul style="background-color:AntiqueWhite;font-size:18px;">
<li><strong><a href="{{url}}">{{key}} - {{summary}}</a></strong>
<ul style="background-color:AntiqueWhite;font-size:18px;">
<strong><li>Description:</strong> {{description}}</li>
</ul>
</li>
</ul>
{{/}}
{{/}}

Darryl Lee
Community Champion
June 26, 2023

Nice!

OH! You just solved a problem I was trying to figure out a few weeks ago:

Actually, now that I read @Bill Sheboy's response more closely, that's exactly what he was suggesting (DOH). 

And yeah, I was trying to avoid having to replicate the block for EVERY component. But maybe I'll just bite the bullet and do it...

Suggest an answer

Log in or Sign up to answer