JIRA Automation - How to validate that a smart value exists

Ryan Pope June 30, 2020

I have several automation rules that work to keep my Epics, Stories, Sub-task, Bugs, and Tasks all in sync where necessary. The idea is that there is only 1 rule per transition (from status A to B) and that rule will handle all the use cases. Currently, the below rule works almost flawlessly, with one exception. In the use case of a Sub-task of a Story that is in an Epic. When the Sub-task triggers this rule, it will correctly transition the parent Story, if necessary, then will transition the Epic related to the Story, if necessary, and it ensures that there is an assignee on a triggering Sub-task and it's parent.

1 of 2.JPG2 of 2.JPG

My issue in the above example is when the Story is not in an Epic my rule results in Some Errors (the For JQL statement in the second image). It will correctly continue and finish executing the rest of the rule but when it attempts to check the {{issue.parent.Epic Link}} value, I receive the following error:

"JQL search failed for some issues. This is most likely because the JQL with smart-values was not valid for this query:"(key = "") AND (project in (xxxxx))" - The issue key '' for field 'key' is invalid."

I could just leave it as is and everything will work fine aside from the partial failure to find an Epic when there isn't one, but I would love to be able to distinguish actual failures from these, so to speak, expected failures. Is there a way to validate that the parent of a triggering Sub-task has an Epic Link before attempting to take action on the Epic? Or more generically, is there a way to validate a smart value exists without ending in a partial failure of the rule?

2 answers

1 accepted

1 vote
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.
June 30, 2020

Hi @Ryan Pope 

I am unable to answer if there is more generic error trapping for smart values.

Your branch on the {{issue.Parent.Epic Link}} is already inside of an IF/ELSE clause, so could you put a IF condition before the branch, trapping the case of no Epic Link?

Best regards,

Bill

Ryan Pope June 30, 2020

Hi @Bill Sheboy 

Thanks for the response!

I have actually tried adding the same smart value to a JQL Condition with no inner action and received the same error. This is the expected JQL result when querying for something like:

key = ""

So I don't think I will be able to query for the Epic Link of a Parent without sometimes getting an error, unless there is another way of conditioning for this that I am overlooking.

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.
June 30, 2020

Hi, and sorry I wasn't clear in my suggestion...

When I am uncertain if a field will have a value (and the default values won't help), I put a simple condition to check for not-empty before proceeding.  I was suggesting adding such a condition before your JQL branch.  That should prevent the error from occurring because the branch would not execute.

Ryan Pope June 30, 2020

That's kind of the issue. I can't do a simple Related Issues Condition check right before the JQL branch because the condition doesn't have the context of the Sub-tasks Parent, which is what would allow me to check if that Parent has an existing Epic. The Related Issues Condition allows me to check the Parent Epic of the STORY that triggered this rule exists. So if I am not within a For Parent Branch when the rule is triggered by a Sub-Task, then that Related Issues Condition check will never have a chance to succeed.

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.
June 30, 2020

Gotcha.  At that same point in the flow, could you use a Lookup action to get at the parent with JQL, test the lookup result with a condition for an epic link, and then branch?

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2020

Hi @Ryan Pope ,

I think the way that you'd want to solve this is to keep the For JQL as the last part of your branch and add a guard before hand so it only executes if there is one. Like so:

 

1.png2.pngHopefully that makes sense!

Cheers,

Simeon.

Like # people like this
Ryan Pope July 1, 2020

@Simmo 

Thanks for the response!

That would be ideal, I agree. Currently, that For JQL branch is within the if portion of an if/else condition, which means at that level I can only add new Actions or Branches.

I did however take your advice on the Advanced Compare Condition, which I had previously overlooked, and added it to another if/else block at the bottom, outside of my initial if/else block. This seems to be working correctly!

 

1 of 2.JPG2 of 2.JPG

 

@Bill Sheboy The Lookup Action was still returning the same error, as that is the expected JQL output.

Thank you both for the suggestions! I greatly appreciate it!

Like Bill Sheboy likes this
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.
July 1, 2020

Hi, @Ryan Pope .  I am glad you got this to work.  This one was a good example of several techniques: working around no branch nesting, validating attributes at various levels, etc.

Please consider marking this one as solved so others can search and get the benefit of what you learned.  Thanks!

1 vote
Wojciech Wardaszko _HeroCoders_
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.
June 3, 2022

To test if your value exists, make an automation rule that would put your smart value in the issue description (with some trigger, like a transition) and then trigger it - if the smart value exists, it will return the numerical or string you need to find, and if it doesn't, the description will not update or display a string you tried instead.

Suggest an answer

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

Atlassian Community Events