Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,458,622
Community Members
 
Community Events
176
Community Groups

How to define action for empty smart value?

Hello,

I have a following script that lists issues in Slack message depending on issue priority:

*{{issue.summary}}* has been completed *({{Perforce Branch.value}} {{Platform Options.value}} {{Build exe.value}}*).
*CL:* {{Revision}}
*Link:* <{{issue.url}}|{{issue.key}}>
*Tester:* {{initiator.displayName}}

*Results:*

:blocker: *Blocker*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Blocker"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}

:bangbang: *Critical*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Critical"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}

:large_red_square: *Major*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Major"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}

:large_green_circle: *Normal*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Normal"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}

:large_blue_circle: *Minor*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Minor"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}

 However, I'm not sure how to add to the script when there is, say, no Minor issues? If there is nothing to print, currently there's just empty space after the heading - but I'd like it to say something like ":tada: No new Minor issues found!" Not just sure what IF or NOT condition I should be referring to?

Pinging @Mykenna Cepek as you've provided great answers before! :)

1 answer

1 accepted

1 vote
Answer accepted

Wow, my first shout-out right in the OP. I'm humbled, @Jenni !

So, one option is to use nested #if statements to suppress an entire section:

{{#if(equals(0,0))}} {{#if(equals(1,1))}} hello {{/}} {{/}}

But that's starting to get excessive and hard to read.

Something else to consider would be to pull out most of the #if logic into conditionals in the rule before the Slack action, and build variables for the output. Then when creating the slack message:

{{#if(not(myvar1.equals("x")))}}
{{myvar1}}
{{myvar2}}
{{/}}

or whatever.

Note that I've not had good success with defining blank variables in automation. That's why my example above checks against "x". There may also be issues with newline in variables.

So the pseudocode for one section might be like:

  • action: set variable(s) to "x"
  • conditional: if priority.name = "Major" then set variable(s) to real values

I hope that makes sense.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events