Forums

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

Smart Values : Using Conditionals (IF) in Lists

Rick Moerloos November 29, 2022

Given a trigger, Field Value Changed, I want to create a Smart Value (Create Variable) containing a string of filtered label values (label starts with 'team/').

Example:

Issue

- Labels: team/abc team/def another-label

Expected Result: Variable contains

team/abc team/def

 

I tried the following:

{{#labels}}{{#if({{.}}.startsWith("team/"))}}{{.}} {{/}}{{/}}

Error: Could not extract smart value parameter: {{.: {{#labels}}{{#if({{.}}.startsWith("team/"))}}{{.}}{{/}}{{/}}

 

{{#if(issue.labels.startsWith("team/"))}}{{.}} {{/}}

Result: Variable is empty

 

This works:

{{#labels}}{{.}} {{/}}

But returns all the labels.

I know I am close, but the #IF is tripping me up.

 

1 answer

1 accepted

1 vote
Answer accepted
Darryl Lee
Community Champion
November 29, 2022

Hi @Rick Moerloos , I'm working off of this article: 

https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

and this reference: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/

I think what you want is:

{{#issue.labels}}
{{#if(startsWith("team/")) }}{{.}}{{/}}
{{/}}
Darryl Lee
Community Champion
November 29, 2022

(The trick here is that each label will automatically get iterated through by the IF, so you don't need to include it as {{.}})

Rick Moerloos November 30, 2022

Thank you, Darryl!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events