---
title: "How to use a path variable to enable or disable various rules"
description: "Using a path variable lets you enable or disable rules based on a custom dataview's rule status. This method adjusts rule logic dynamically without using active times or manual rule disabling."
url: "https://docs.itrsgroup.com/docs/faq/geneos/4530548085661-geneos-how-to-use-a-path-variable-to-enable-or-disable-various-rules/index.html"
---
## Solution

This is an alternative to linking an active time to a rule or disabling or enabling a rule in the Gateway Setup Editor.

This solution entails creating a custom dataview with a dataview name and rule status columns, and having a new or existing rule reference the rule status value using a path alias and path variable. Once referenced, you can adjust the logic in the rule to trigger based on the dataview's rule status value.

The following is an example FKM rule where we set the FKM status cell to critical if the status contains a string like `NOT_FOUND` or `FAIL`. Notice this rule targets the status columns on both the `Beta FKM` and `Generic_FKM_Testing_Sampler` dataviews.

![FKM status rule](https://docscdn.itrsgroup.com/faq/images/geneos/FKM-status-rule.png)

Let's say we want this rule to be active but want the ability to disable some or all parts of the rule during downtime or maintenance on the fly without using active times or disabling the rule. You can create a custom dataview like the one below that lists Dataview Name and its Rule Status.

You can then modify your rule to trigger based on the dataview's Rule Status value. The following steps set this up.

![Dataview Status Toolkit View](https://docscdn.itrsgroup.com/faq/images/geneos/dataview-status-toolkit-view.png)

## Create a Path Variable that will grab the rule target's dataview name

1. Go to the Rule's **Advanced** tab and click **Add new** in the Path variables section.
2. Set the path variable name to `rowname`.
3. Under the Value section, remove the value `true` and right-click on the white space of the Value section and select **Target names > dataviewName**.

![dataviewName target value for rowname](https://docscdn.itrsgroup.com/faq/images/geneos/set-path-variables.png)

## Add Path Variable to Path Alias referencing Rule Status in the Dataview Status Toolkit View

This is how we match the rule target's dataview name and the rowname in the Dataview Status Toolkit View to grab the corresponding Rule Status value.

1. Go to the Rule's **Advanced** tab and click **Add new** in the Path alias section.
2. Name the path alias `rule\_status`.
3. Drag and drop the **Rule Status** cell from any row in the Dataview Status Toolkit View to the xpath field.
4. Click the **EDIT...** button next to the Xpath.

![Edit path alias](https://docscdn.itrsgroup.com/faq/images/geneos/edit-path-aliases.png)

5. Hover over the Row element and click **EDIT**.
6. In the Element Properties window, set the name to `$rowname`.
7. Close the Element Properties window.
8. Click the **OK** button in the Edit Path window.

![Element Properties](https://docscdn.itrsgroup.com/faq/images/geneos/set-rowname-element-properties.png)

## Add logic in the rule block to determine if the rule is active depending on the path alias value

Now that we have the `rule_status` path alias set in the Advanced tab, we can now reference it in the rule block.

In the example rule block, we are setting a variable called `$(rulestat)` that references the `rule_status` path alias.

```
set $(rulestat) path "rule_status" value
```

In this rule, we are looking to set the cell to critical if the status contains a string like `\*NOT\_FOUND\*` or `\*FAIL\*` and the **Rule Status** cell for the corresponding dataview is set to `Active`. The `elseif` block is adjusted as follows:

```
elseif $(rulestat) = "Active" and value like "*NOT_FOUND*" or value like "*FAIL*" then
```

Below is the adjusted rule block:

![FKM status rule block](https://docscdn.itrsgroup.com/faq/images/geneos/updated-rule-block.png)

Notice each dataview now sets the status to critical based on the Rule Status value as well.

![FKM Testing Sampler output](https://docscdn.itrsgroup.com/faq/images/geneos/FKM-testing-sampler-output.png)

![Beta FKM output](https://docscdn.itrsgroup.com/faq/images/geneos/beta-fkm-output.png)

To check the Rule XML, see [FKM_Status_Rule.xml](/faq/downloads/geneos/FKM_Status_Rule.xml "Download the FKM Status Rule XML file")

## Related documentation

- [Path Variables](https://docs.itrsgroup.com/docs/geneos/current/processing/monitoring-and-alerts/geneos_rulesactionsalerts_tr/index.html#rules--rule--pathvariables)
- [XPaths User Guide](https://docs.itrsgroup.com/docs/geneos/current/processing/gateway-administration/geneos_xpath_ug/index.html)


