---
title: "How to condition running of actions"
canonical: "https://support.appfire.com/space/SUPPORT/89149424/How%20to%20condition%20running%20of%20actions"
format: markdown
---
# Description

When writing CLI or other scripts, it is useful to be able to condition running an action or actions based on information available at runtime or as a parameter in the script. To make it easier to do this especially for CLI scripts, [CLI 7.6](https://appfire.atlassian.net/wiki/spaces/ACLI/pages/60564474) provided a new ***runIf*** action that will only run the action(s) when the condition is met. 

# Details

The ***runIf*** action is essentially the same as the ***run*** action with additional parameters to specify the condition that is used to determine if the action(s) should be run or not.

## *runIf*

> Run actions only if a regex based condition is met. Other parameters and behavior are the same as the run action. By default the regex is used as a find operation in the value. Options parameter can be set to one or more of the following to modify the default behavior: literal - to treat the regex string as a literal string, exact - to require an exact match of the value, negative - to reverse the condition so a match means do NOT run action.
> 
>     Required parameters: value, regex, file or input or standard input
> 
>     Optional parameters: common, continue, simulate, clearFileBeforeAppend, encoding, findReplace, findReplaceRegex

# Examples

##### **Only run on first day of the month**

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

##### **Only run if the script parameter lead is set to bob**

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