I am trying to create a condition that triggers when there is at least one person who is not the initiator is in the assignee or reporter field, or the watchers list.
In other words, the rule should trigger when any one of these is true:
I am currently trying to create this via a JQL query that reads
{{issue.assignee.emailAddress.remove(initiator.emailaddress)}} != empty OR {{issue.reporter.emailAddress.remove(initiator.emailaddress)}} != empty OR {{issue.watchers.emailAddress.remove(initiator.emailaddress)}} != empty
However I am getting the bug
(!= empty OR reporter@example.com != empty OR watcher1@example.com, watcher2@example.com != empty))" - Error in the JQL Query: Expecting a field name but got '!='. You must surround '!=' in quotation marks to use it as a field name. (line 1, character 27)
I am the assignee in my test ticket, and it seems this rule is removing my name entirely, so it is creating a bug. How should I fix my JQL, or is there an easier way to do this?
I also previous tried to do it via multiple Advanced Compare Conditions, but could not add OR functionality to this.
Thanks!
I recommend using an advanced compare condition, testing for equals, rather than a JQL condition.
Remember that JQL is not a SQL or programming language, and...
The issue is the JQL condition requires you to use well-formed JQL, and your use of smart value expressions on the left-side of comparisons can collapse to null. With JQL, the left-side of comparisons must be a valid issue field. Your audit log shows that you are trying to compare null (the absence of information) to empty, which cannot work with JQL.
Kind regards,
Bill
Hi @Bill Sheboy
Thank you for the suggestion. I tried doing it with Advanced Compare Conditions, but could not figure out how to use OR logic with this. I am trying to make the rule trigger when any one of the following is true, not when all three are true.
That is why I originally tried using JQL, so that I could use OR functionality.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sadly, there is no built-in OR for condition rule components...but there is a built-in OR function that can be used with conditional logic. Sorry if that is confusing.
Thus you can do this in one advanced compare condition, although it is messy:
first value:
{{#if(or(exists(issue.assignee.emailAddress.remove(initiator.emailAddress)),
or(exists(issue.reporter.emailAddress.remove(initiator.emailAddress)),
exists(issue.watchers.emailAddress.remove(initiator.emailAddress)))))}}true{{/}}
condition: equals
second value: true
The nested or() structure is needed because that function can only take two parameters. And I substituted to use exists() to test for non-null.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
Thanks for linking the OR documentation, that's new information for me!
I tried this, but it appears that the EXISTS function is always returning true. In the screenshot below, you can see the first audit log evaluating the smart value existing as true, however the second log is erroring out even though it is trying to evaluate the exact same smart value.
Do you have a link to the EXISTS documentation? I tried searching for that but could not find it.
Also, what does the # in your {{#if...}} do? I also saw that in the OR documentation but could not find its purpose.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Regarding that expression collapsing to always true, I believe that is because after the remove() happens, you are left with an empty string, rather than null...and that would always exist. And so another method must be used...
Instead we can use not(equals(yourTestString,"")) for the comparison to an empty string rather than null. The replacement would be this:
{{#if(or(not(equals(issue.assignee.emailAddress.remove(initiator.emailAddress),"")),
or(not(equals(issue.reporter.emailAddress.remove(initiator.emailAddress),"")),
not(equals(issue.watchers.emailAddress.join(",").remove(initiator.emailAddress),"")))))}}true{{/}}
Conditions like this can be messy, so it is often better to build them piece by piece
Here is the exists documentation: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#exists
The # in the {{#if(some Boolean expression)}} is the syntax for for using a conditional logic smart value expression.
UPDATED: I updated the watchers component to handle the field list joining to a single text string before the remove operation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That all works, thank you so much!!
And thanks for relinking, I missed that part of the documentation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, spoke too soon. It appears that the assignee and reporter portions work correctly, but the watchers part still always evaluates to true, even if the value is empty.
I suspect this is because the assignee and reporter field are single user fields, and the watcher field handles multiple users.
In the below screenshot, there were no watchers but it still evaluates as true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am glad you noticed the watcher field is a list, and so when we referenced {{issue.watchers.emailAddress}} that expanded into a list...even when empty. One work-around is to join that list into a single text string first, like this:
{{issue.watchers.emailAddress.join(",")}}
Then when the initiator's email address is removed, the string will either be empty or not, with no empty list left behind.
And so the updated condition expression could be this:
{{#if(or(not(equals(issue.assignee.emailAddress.remove(initiator.emailAddress),"")),
or(not(equals(issue.reporter.emailAddress.remove(initiator.emailAddress),"")),
not(equals(issue.watchers.emailAddress.join(",").remove(initiator.emailAddress),"")))))}}true{{/}}
And as a reminder, using automation rules often requires learning and experimentation. I encourage you to try things and make adjustments when rules do not work as you expect. This includes building up complicated expressions, piece by piece, to test them. Although the community can help, you and your team will know better as your Jira site configuration will be different than that of others.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This continued to evaluate as true, so did not work.
I did manage to create the following, which finally worked:
{{#if(or(not(equals(issue.assignee.emailAddress.remove(initiator.emailAddress),"")),
or(not(equals(issue.reporter.emailAddress.remove(initiator.emailAddress),"")),
issue.watchers.emailAddress.join(",").remove(initiator.emailAddress).length.gte(1))))}}true{{/}}
This joins the email addresses into a text string, checks the length of the string, and then checks if it is greater or equal than (gte) 1.
I unfortunately do not have access to the technical team that set up our Jira server instance. I am in a nontechnical role who happens to have the most technical familiarity on my immediate team, so the implementation of these rules is left up to me, Google, and the wonderful people here. I really appreciate your patience and willingness to help :)
Thanks again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well done; I am glad to learn you have something working. You could use that same length test technique for assignee and reporter if you want to be consistent.
And...sorry about that as I copied from the incorrect version that still used exists() when I fixed the watcher issue; I updated the above post to the one I know works in my test rule, using not(equals(expression, "")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What app are you using in your system to set this JQL condition, as this is not ootb functionality within Jira Server?
Are you able to add screenshots in detail as well?
This will help community members to hopefully provide yoo with a solution
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 suggestion Marc. I was not part of the team who set up our Jira so I'm unsure if this is ootb functionality, I just know I have access to JQL conditions.
Here's a screenshot of the rule:
Here's a screenshot of the error:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.