I want to block a transition if fixversion contains "-UPDATE" in it
Asked by Yugandhar Kumar Chintamaneni:

Hi,

I want to write automation rule to block a transition if fixversion contains "-UPDATE" in it.

is it possible?


Answers:
author: Maciej Dudziak _Forgappify_
body: Hi [@Yugandhar Kumar Chintamaneni](/t5/user/viewprofilepage/user-id/5524803)

I am not sure if it can be done with out-of-the-box validators, but for sure, it is possible with Jira expression-based validator. Expression you need is as follows:

```
!issue.fixVersions.some(version => version.name.includes('-UPDATE'))
```

There are several options available on the Atlassian [marketplace.](https://marketplace.atlassian.com/search?query=jira%20expression%20validator)

I am from Forgappify, and we developed Jira Expression Validator, which is part of the [Workflow Building Blocks for Jira](https://marketplace.atlassian.com/apps/1233642/workflow-building-blocks-for-jira?hosting=cloud&tab=overview) app.

I would appreciate it if you could give it a try.

Cheers


author: Bill Sheboy
body: Hi [@Yugandhar Kumar Chintamaneni](/t5/user/viewprofilepage/user-id/5524803) -- Welcome to the Atlassian Community!

Automation rules trigger *after an event has occurred*, such as an issue transition. They cannot block or prevent the event.

Instead investigate using workflow validators, perhaps from an addon, to prevent the transition.

Kind regards,  
Bill

comments: author: Yugandhar Kumar Chintamaneni
body: Hi [@bill](/t5/user/viewprofilepage/user-id/4638362) , I could not find a correct validator which can do this. could you please guide me


author: Bill Sheboy
body: To perform that type of validator on Fix Version, please investigate marketplace addons as the built-in validators will not support the field.


author: Mikel Garcia Bartolome
body: 1. **Navigate to Automation Rules:**

   * Go to your Jira Cloud instance.
   * Click on the gear icon (??) to go to the Jira settings.
   * Select "System" and then "Global Automation" or "Project Automation" under "Automation" depending on whether you want this rule to apply globally or to a specific project.
2. **Create a New Rule:**

   * Click on "Create Rule" to start a new automation rule.
3. **Add Trigger:**

   * Select a trigger that corresponds to a transition, such as "Issue transitioned".
4. **Add Condition:**

   * Click on "New condition" and select "Advanced compare condition".
   * Configure it as follows:
     * First value: `{{issue.fixVersions.name}}`
     * Condition: `contains`
     * Second value: `-UPDATE`
5. **Add Action:**

   * Add an action to block the transition.
   * Jira Automation does not directly support blocking transitions, so you can instead add an action to notify the user and possibly move the issue back to its previous status or set a flag.
   * For example, you can use the "Edit issue fields" action to add a comment explaining why the transition is not allowed.
6. **Complete the Rule:**

   * Give your rule a name and description.
   * Turn on the rule.

Here is an example of how you might configure the rule in detail:

### Step-by-Step Example {#toc-hId-2144674349}

1. **Create a new rule:**

   * Click on "Create Rule".
2. **Add Trigger:**

   * Choose "Issue transitioned" trigger.
   * Configure the transition details (e.g., "From status" and "To status").
3. **Add Condition:**

   * Click on "New condition".
   * Select "Advanced compare condition".
   * Configure the condition:
     * First value: `{{issue.fixVersions.name}}`
     * Condition: `contains`
     * Second value: `-UPDATE`
4. **Add Action (Notify User and Move Issue Back):**

   * Click on "New action".
   * Select "Send email" or "Send Slack message" to notify the user that the transition is blocked.
     * Email Example:
       * To: Assignee (or Reporter, or any other appropriate user)
       * Subject: Transition Blocked
       * Body: The transition was blocked because the `fixVersion` contains "-UPDATE".
   * Optionally, add another action to transition the issue back to the previous status or to set a flag:
     * Click on "New action".
     * Select "Transition issue" to move it back to the previous status.
5. **Save and Activate the Rule:**

   * Name your rule (e.g., "Block Transition for -UPDATE in fixVersion").
   * Turn on the rule.

comments: author: Mikel Garcia Bartolome
body: Here's an example of how the rule might look in JSON format if you export it from Jira (you can format JSON [here](https://jsonlint.com/)):

{  
"name": "Block Transition for -UPDATE in fixVersion",  
"trigger": {  
"type": "issueTransitioned",  
"config": {  
"statusFrom": \["Any Status"\],  
"statusTo": \["Any Status"\]  
}  
},  
"conditions": \[  
{  
"type": "advancedCompareCondition",  
"config": {  
"firstValue": "{{issue.fixVersions.name}}",  
"compareType": "contains",  
"secondValue": "-UPDATE"  
}  
}  
\],  
"actions": \[  
{  
"type": "sendEmail",  
"config": {  
"to": "assignee",  
"subject": "Transition Blocked",  
"body": "The transition was blocked because the fixVersion contains \\"-UPDATE\\"."  
}  
},  
{  
"type": "transitionIssue",  
"config": {  
"status": "Previous Status"  
}  
}  
\]  
}


author: Yugandhar Kumar Chintamaneni
body: Hi [@Mikel Garcia Bartolome](/t5/user/viewprofilepage/user-id/5308981) ,

Thanks for your reply.

Comparison worked and I am able to add a comment.

But issue is that it is transitioned to the next state. I want to block it and keep it in the previous status only.

in the below example it should be in Test in progress. But it is in workdone after i run this rule

![status.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/333677i11352124FD49C473/image-size/large?v=v2&px=999 "status.PNG")


author: Mikel Garcia Bartolome
body: In Jira Automation, there isn't a direct way to "block" a transition during the event itself, but you can simulate this by immediately transitioning the issue back to its previous status if it contains "-UPDATE" in the `fixVersion`. Here is how you can set up the rule:

**Add Action to Transition Back:**

* Click on "New action".
* Select "Transition issue".
* Configure it to transition the issue back to the previous status.
* Use the smart value `{{fieldChange.fromString}}` to transition it back to its previous status.


Tags: cloud

jira-cloud