---
title: "Run actions conditionally in ACLI scripts"
canonical: "https://support.appfire.com/space/ACLI/1940127919/Run%20actions%20conditionally%20in%20ACLI%20scripts"
format: markdown
---
> Macro (aura-html)

When creating ACLI scripts, you may need to control whether an action runs based on dynamic values available at runtime or passed in as parameters. Starting in **CLI 7.6**, you can use the `runIf` action to run specific commands only when a condition is met—streamlining logic and improving script efficiency.

Use the `runIf` action when you want to:

- Run an action only when a certain value matches a pattern.
- Avoid cluttering your script with complex external logic.
- Automate behavior based on time, input parameters, or other runtime data.

## How `runIf` works

The `runIf` action functions similarly to the `run` action, but with additional parameters that define a condition. The condition uses a regular expression to evaluate whether to proceed with executing the input action(s).

### Required parameters

- `value`: The value to evaluate.
- `regex`: The regular expression to test the value against.
- One of the following:
  - `file`
  - `input`
  - Standard input

### Optional parameters

- `common`
- `continue`
- `simulate`
- `clearFileBeforeAppend`
- `encoding`
- `findReplace`
- `findReplaceRegex`

### Options for condition evaluation

To customize how the condition is evaluated, use the `options` parameter. You can include one or more of the following:

- `literal`: Treat the `regex` as a literal string.
- `exact`: Require an exact match of the `value` to the `regex`.
- `negative`: Reverse the logic—**do not run the action if the condition matches**.

## Examples

### **Run only on the first day of the month:**

```
--action runIf --value %now% --regex 01 --dateFormat dd --input "--action ..."

```

### **Run only if the script parameter **`lead`** is set to **`bob`**:**

```
--action runIf --value %lead% --regex bob --options exact --input "--action ..." --input "--action ..."

```

> ✅ **Tip: **Use `runIf` to keep your scripts clean and focused by embedding simple conditional logic directly into your automation flow.