---
title: "Conditional execution/validation using a Groovy expression"
canonical: "https://support.appfire.com/space/JMWE/461996060/Conditional%20execution%2Fvalidation%20using%20a%20Groovy%20expression"
format: markdown
---
> Macro (aura-html)

The Post functions and Validators provided by the JMWE add-on have a `Conditional execution/Conditional Validation` section to control the execution of the post-function/validator respectively. You need to provide a [Groovy script](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461537291) in the editor based on whose result, the post-function/validator will either be executed or skipped.

**On this page:**


## Conditional execution of a post-function

## Conditional validation

## Expected Value for a condition

The value should be either a boolean value (`true` or `false`), or more generally any value that will be interpreted as either "truthy" or "falsy". <span style="color: #333333">Click on the </span>**<span style="color: #333333">Expected Value</span>**<span style="color: #333333"> tab of the Groovy editor to know the expected value. </span><span style="color: #333333">You can also quickly test your written script against any issue using the </span>[<span style="color: #333333">script tester</span>](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78056956)<span style="color: #333333"> </span><span style="color: #333333">tool. For example:</span>

**Groovy expressions returning a "truthy" value: **

- `1 == 1 `or any boolean expression that is `true`
- `issue.get("assignee") `if the issue is assigned
- `issue.getAsString("assignee") == "jdoe" `if the issue is assigned to user "jdoe"
- `issue.get("description") `if the issue's description is not empty

**Groovy expressions returning a "falsy" value: **

<span style="color: #172b4d">Any value will be interpreted as "falsy" (the equivalent of</span><span style="color: #172b4d"> </span>`false`<span style="color: #172b4d">)</span><span style="color: #172b4d"> </span>*except*<span style="color: #172b4d">:</span> true, a non-empty string, a non-empty Collection, a non-empty Map, a non-empty array, a number different from zero (`0`)

For example, false, 0, "", []

Below are a few use cases that detail the usage of these functionalities.

## Use cases

### Conditional execution

:light_bulb_on:  A*utomatically escalate an issue if it is being raised with a "Blocker" priority.*

<details>
<summary>Steps</summary>

> ℹ️ - Add the *Transition issue** *post-function to the **Create** transition of the issue's workflow.
> ℹ️ - Input the transition name or ID of the transition that escalates the issue.
> ℹ️ - Select the `Only if condition is true` option in `Conditional execution `and write the following code in the editor.
> ℹ️ - Place the transition at the end of the list of post-functions.
</details>

:light_bulb_on:* Auto-assign a created issue to the Product owner, only if the issue is a Bug*

<details>
<summary>Steps</summary>

> ℹ️ - Create a **Product Owner** project role, with the product owner as the only member.
> ℹ️ - Add the *Assign to role member *post-function to the **Create **transition of the issue workflow.
> ℹ️ - Select `Product Owner` as the project role.
> ℹ️ - Select the `Only if condition is true` option in `Conditional execution `and write the following code in the editor.
</details>

:light_bulb_on:* **Add a comment on the Epic when its user stories of a client-side project are resolved.*

<details>
<summary>Steps</summary>

> ℹ️ - Add the *Comment linked issues* post-function to the **Resolved** transition of the Story workflow.
> ℹ️ - Choose the issue link type `has Epic` and write the following content in the `Comment` section.
> ℹ️ - Select the `Only if condition is true` option in `Conditional execution `and write the following code in the editor.
</details>

### Conditional validation

:light_bulb_on: <span style="color: #000000">*Allow the members of the *</span>`Managers`<span style="color: #000000">* project role to omit the comment*</span>

<details>
<summary>Steps</summary>

> ℹ️ - Add the *Comment Required Validator* to the transition of the issue's workflow.
> ℹ️ - Select the `Conditional Validation `option in `Validator scope `and write the following code in the editor.
</details>

:light_bulb_on: *Force the user to provide a Fix Version/s on resolving a bug, only when the resolution is "Fixed"*

<details>
<summary>Steps</summary>

> ℹ️ - Add the *Field is required Validator* to the **Resolve** transition of the issue's workflow.
> ℹ️ - Select the `Conditional Validation `option in `Validator scope `and write the following code in the editor.
</details>