Forums

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

Notification at slack - using smart variables

Hugo Moraes Neto May 28, 2023

Hi folks, I'm trying to notify my team via Slack about issues stuck in a specific column.

The alert is daily:

 1.png

 

The problem is that I define the text for the notification as:

"Today we have {{issueList.size}} issues stuck in the status 'Awaiting Code Review'"

{{#lookupIssues}}
{{url}} | {{summary}} | {{now.diff(issue.status.lastUpdated).days}} dias.
{{/}}

 

The variables {{issueList.size}} and {{now.diff(issue.status.lastUpdated).days}} are not being displayed.

2.png

 

can your help me please

1 answer

1 accepted

3 votes
Answer accepted
Bill Sheboy
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.
May 28, 2023 edited

Hi @Hugo Moraes Neto 

I noticed a few things in your use of Lookup Issues that might help...

(1) The results of Lookup Issues is a list, and so use the size function to learn how many results there are for the JQL.  I recommend this, as it includes a default value of 0

{{lookupIssues.size|0}}

(2) As your lookup could be empty, I recommend adding some conditional logic to handle that case before sending the Slack message.

(3) I do not believe there is a field for the last update to a status which is available.  Do you have an add-on for JQL that provides that?  If not, you could modify your JQL and smart values to use either the Updated field or change the query to look for issues where the status has not CHANGED within a certain timeframe.  For example: 

project = myProject AND status = myStatus AND NOT Status CHANGED AFTER -2d

(4) Finally, when a rule is inside of an iterator like for Lookup Issues, you only need to use the field names and not the prefix issue.  In fact, inside the other rule information is not visible at that scope.  For example:

{{#lookupIssues}}
{{url}} | {{summary}} | {{updated.diff(now).days}} dias.
{{/}}

Please try those things to see how they help.

Kind regards,
Bill

Hugo Moraes Neto May 29, 2023

Hi friend, thanks for your help. I made some changes, but why is the diff date the same result in all lines?

 

 

{{#lookupIssues}}
{{now}}| {{updated}} |{{now.diff(updated).days}}
{{url}} | {{summary}} | {{now.diff(updated).days}} dias.
{{/}}

 

4.png

Bill Sheboy
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.
May 29, 2023

My apologies, as I forgot there is a defect/behavior of the order of dates with diff() when using now...as that cannot be first.  Please try this:

{{updated.diff(now).days}}

I updated my earlier post to reflect this. 

Like • Hugo Moraes Neto likes this
Hugo Moraes Neto May 29, 2023

thanks.. now is perfect. ;)

Like • Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events