Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,376
Community Members
 
Community Events
165
Community Groups

JIRA Automation - How to validate that a smart value exists

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

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

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.

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.

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.

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 Jun 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

@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

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!

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
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,854 views 37 49
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you