Hello,
I have Jira Automation script that sends message to Slack when issues with certain conditions are created.
However, I'd want to add a Slack emoji to the message whenever the issue is Blocker by priority.
Currently my automation script has the following line:
Priority: {{if(priority(Blocker))}}:blocker:{{/}} *{{priority.name}}*
Which, hopefully would print ":blocker: Blocker" when it's a blocker, and otherwise just the name of the priority, such as "Normal". For clarification, :blocker: is the name of the emoji I'm trying to call on Slack.
Is the condition correct? So far it doesn't seem to be working.
Well, that wasn't as trivial as it looked to solve. :-|
I'll start with the solution:
Priority: {{#if(equals(issue.priority.name,"1-Urgent"))}}:exclamation: {{/}}{{issue.priority.name}}
which produces in Slack, in our environment:
HOWEVER, we have renamed our Status names to use a numeric prefix (so they will sort correctly by priority always). So in your case, of course, you'll want to use "Blocker" instead.
- - - - - - -
Here's why this ended up being non-trivial to solve:
Note: I don't like having to rely on priority.name, as names can change (as I did once in our Jira instance, when adding the numeric prefixes). Relying on names could be considered brittle.
In our case, the internal priority numbers don't always match the prefixes used for priority names, as illustrated below. So I'd probably use priority.name in our rules for maximum clarity. Note how helpful it was to use the Audit Log action to confirm the actual values for the priority field:
Thank you for your message! My workaround for this was to do branched conditions with JQL checks for what the priority is, and then have customised Slack message for each priority with corresponding emojis. Yes, it was more work but in the end it was clearer than dealing with conditional logic.
I'll keep this in mind though! The "Log action" was new to me, I need to try that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since your original question was "Is the condition correct?", and I believe I answered it, would you be willing to accept my answer? That's important feedback, especially for Community Leaders. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.