I am currently using this logic to filter for issues within an issue lookup to filter for the bug tickets.
{{#lookupIssues}}
{{#if(equals(issueType.name, "Bug"))}}
Bug Fixes:
• {{key}} - {{summary}}
{{/}}
{{/}}
However I cannot find a way to filter exactly like this but for all tickets that are NOT the "Bug" issue type.
I feel I am missing something obvious, I tried a lot of docs online but found nothing to work.
How would I do this so I can separate them into different lists when sending one message in Slack? Thanks!
Hi @Lewis Smith -- Welcome to the Atlassian Community!
A couple of ways to do this are to use either the NOT() operation around your current condition, or to use the OR() operation to test the other issue types. (Please note: this version of OR() only accepts 2 parameters, and so chaining is needed, such as OR(A, OR(B,C))
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#not
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#or
Once you have figured out your filtering, just add the sections to your Slack message:
...bug info
...non-bug info
Kind regards,
Bill
Thank you for your reply!
It seems this was the solution after all, I was just doing it wrong in terms of my formatting. I am now able to filter for both of these how I would like!
I am now wondering if you could help me expand on this so I could further my query.
I really want to make this only return something if the issue count of "Bug" or not "Bug" is > 0 or perhaps if there is 0 of this issue type then return something else.
for example:
{{#lookupIssues}}
{{#if(equals(issueType.name, "Bug"))}}
Bug Fixes:
• {{key}} - {{summary}}
else
There are no bugs this time.
{{/}}
{{/}}
OR
{{#lookupIssues}}
{{#if(equals(issueType.name, "Bug") AND issues.size > 0)}}
Bug Fixes:
• {{key}} - {{summary}}
{{/}}
{{/}}
Could you help me with how I would achieve this? Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately, I do not believe that is possible with a single operation / lookup.
Fortunately, you are using Jira Cloud, and so may use the Create Variable action to help, although there are a few ways to do this. Also, {{lookupIssues.size|0}} will return the count of issues returned by the lookup.
Thus one way to do this is to capture the two filter results in created variables, and just use them:
You may need to experiment until you get the formatting you want.
Another way to do this is with 2 calls to lookup issues: call once to get bugs, and save the formatted results in a variable. Later test the size to replace with the "no bugs..." message. And repeat that for the "not bugs" ones.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply!
I tried what you said and it's not working due to the following error:
Here is the rule I have set up, hopefully this can help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That error means that an action/condition/branch is referencing the {{issue}} smart value but you do not have any...or...there is a type and the rule interprets a smart value that way.
I found a typo in my suggestion when creating the varNotBugs variable...which I fixed in my earlier post. (It was missing a parenthesis.) Please check that one first to see if that corrects this error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have updated the logic as you said and I am still getting that error, I also get another error with the variable value.
See here:
This is only fixed when I do this:
Is this correct or am I perhaps doing something wrong here also? Thank you so much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry I missed that closing section to match up!
Is the rule saving?
If so, and the error occurs when the rule runs , please post an image of the audit log details for the run...showing all the information including the error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have managed to fix these errors by changing the if conditions to the following:
Now it seems that it works to some degree but does not output the updated variable inside the IF of "No bug" when there is no issues but instead just leaves it blank on the output.
I am also having issues with the formatting as I would like to get each issue onto a new line but I cannot seem to get this to work either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please show the updated block of actions for "no bug", where you:
For the formatting, you may need to try adding a \n for a new line character after each one or to switch to HTML formatting. Would you post an image of the current message action and what the output in Slack looks like now?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem here is the up to date info you requested.
Here is the rule breakdown:
Here is the variable I make at first:
Here is the variable after it should be updated:
Here is the format of the message being sent to Slack:
And here is the final outout:
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rather than using this in the expression:
{{.}}{{"\n"}}
Perhaps try this
{{.}}\n
So, without the quotation marks and curly brackets.
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.
Hi, Lewis.
After testing a bit I was unable to find a way to get the conditional newline to work in a created variable with markup.
An alternative is to use the variables only for counting issues, and then use that to show your "there are no bugs" messages. This is a variant of what I described earlier, as it uses math operations to count the values in a condition.
{{#=}}0{{#lookupIssues}}{{#if(equals(issueType.name,"Bug"))}}+1{{/}}{{/}}{{/}}
{{#=}}0{{#lookupIssues}}{{#if(not(equals(issueType.name,"Bug")))}}+1{{/}}{{/}}{{/}}
The bugs are:
{{#lookupIssues}}{{#if(equals(issueType.name,"Bug"))}}
* {{key}} - {{summary}}
{{/}}{{/}}
{{#if(equals(varBugCount,"0"))}}There are no bugs.{{/}}
The not bugs are:
{{#lookupIssues}}{{#if(not(equals(issueType.name,"Bug")))}}
* {{key}} - {{summary}}
{{/}}{{/}}
{{#if(equals(varNotBugCount,"0"))}}There are no not-bugs.{{/}}
The reason the zero-count checks AND outputs cannot be done together is inside of an iterator like {{lookupIssues}} ... {{/}}, you cannot refer to anything other than the fields of the lookup.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wow thank you so much, this whole process has helped me understand jira automation a lot more but this is the perfect solution for exactly what I wanted!
I think we can close this off now as that is 100% working!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As there is no comprehensive documentation for automation rules, experimentation is often needed to figure things out :^)
I encourage you to create a test project in Jira, just for testing / playing around with automation rules. This can help to build and test complicated rules, and then copy them over to the desired project when ready.
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.