How can I ensure an Automation rule only runs once for an issue?

andreas
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.
October 10, 2017

I want to ensure we only run a particular rule one time against an issue. How can you do this with Automation for Jira?

2 answers

1 accepted

3 votes
Answer accepted
andreas
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.
October 10, 2017

So there's a few different ways this can be done. A visible way would be to edit the issue and add a label, then check for the presence of this label with a JQL condition.

Another way that's invisible to users is to use entity properties. Your rule would look like this:

  • Trigger: Any trigger
  • Compare condition:
    • First value: {{issue.properties.ruleexecuted}}
    • Equals:
    • Empty (leave field blank
  • Action: Do something like editing the issue
  • Action: Set entity property 'ruleexecuted' = true

 

It looks like this in practice:

run-once.png

 

The actions in this rule will now only execute once for a given issue.  After that, the compare condition will fail since the issue property has a value.

Sebastián Delmastro March 7, 2019

@andreas what happens when needed to run another rule once, but the {{issue.properties.ruleexecuted}} = true because it was edited by another rule.

 

The {{issue.properties.ruleexecuted}} is for every particular rule or for all rules? i.e. an issue can only have one value or it can have several values for every rule?

This is because i have this compare condition en Epics but is telling me on the audit log that the issuesdid not match the condition: i.e. is nos Empty.

 

Thanks!

Like Jean Francois Gelinas likes this
Jean Francois Gelinas November 18, 2021

Hummmm, all rules

Jean Francois Gelinas January 18, 2022

That doesnt work since you cant execute another rule for that issue.

Dalia El-Dib October 5, 2022

@andreas The first condition always fails. I assume because {{issue.properties.ruleexecuted}} is not even an existing issue entity. Did this work for you? Any clues why it will always fail for me

Lennart Verkaik December 5, 2022

This works for me with 5 separate rules. I named the properties 'rule1executed', 'rule2executed', rule3executed', etc. I used this to generate child issues when the status is changed. 

Like Joe Currivan likes this
Joe Currivan May 15, 2023

@Lennart Verkaik  that's a fantastic find. I didn't realize Property smart values could have customized names like that!! 

 

I just tried using names that were friendly to me, and that works too. 

 

For example, I wanted an automation for a Design process and another automation for an Implementation process. So I made the Property smart value names "ruleexecuted-design" and "ruleexecuted-implement" and it works just fine. 

0 votes
Megan Moulton April 17, 2024

Hi everyone! I used this thread and found it super helpful. Because I am a slow learner, here are the exact steps I used to make it so my automation rule only ran as dictated, even if I have multiple if/else statements

 

In this example, I am making sub-tasks when an issue hits certain status. This triggers on creation and transition. 

  1. Because I want the same rule to run based on different conditions, I am using If/Else. The first condition checks my conditions as well as the issue property
    prevent_duplicate_rule.png

  2. Later in this section, I set the actual property name. prevent_duplicate_rule_2.png
  3. You can rinse and repeat for additional if/else statements, just come up with a new property name. Here's the section for new subtasks:
    prevent_duplicate_rule_3.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events