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>
{{/}}
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...
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
{{/}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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>
{{/}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This worked as a loop on the {{#issues}}
<p style="color:white;background-color:orange;font-size:30px;"> 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;"> 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;"> 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>
{{/}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.