# Field rules

### Field rules in aqua

Field rules let you control how fields behave depending on the values selected in the controlling fields.\
This functionality helps you build logic into your projects — making it easier to guide users, enforce consistency, and automate field behavior.

**Field rules** can be applied to:

* Requirements
* Test cases
* Test scenarios
* Defects

{% hint style="warning" %}
Currently, field rules work only with **single-select fields** (either default or custom ones).

Default 'Status' field can't be used with field rules as it's used to define [Workflow](https://docs.aqua-cloud.io/documentation/project-configuration/workflow-configuration)
{% endhint %}

#### Types of field rules

Field rules consist of two main parts: **Restrictions** and **Actions**.

### **Restrictions**

Restrictions define which values are available in one field depending on the value selected in another field.\
They help narrow down options for users or prevent invalid combinations.

**Example**

Let’s say you have **a requirement** where there are two single-select fields:

* **Field name: Field A**\
  Field values: Item 1, Item 2, Item 3, Item 4, Item 5
* **Field name: Field B**\
  Field values: Option 1, Option 2, Option 3, Option 4, Option 5

**You can create a rule like this:**

* If **Field B** value equals Option 1, show only *Item 1* and *Item 2* in **Field A**
* If **Field B** value equals Option 2, show only *Item 3* and *Item 4* in **Field A**
* If **Field B** value equals  Option 3, show *Item 1* and *Item 5* in **Field A**

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2FTUjW2XidCWQ4wuBsen2c%2Fimage.png?alt=media&#x26;token=c3f4d4a6-6cdb-46a3-91ef-c5ec30083f7b" alt=""><figcaption></figcaption></figure>

If no rule is set, it would look like this. Disregarding the selected item in Field B, Field A has a full list of values

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2FBs1OX3iRtZHdsYiYTsAp%2Fimage.png?alt=media&#x26;token=797bd556-4651-4a9d-ab45-0d3cabd099a5" alt=""><figcaption></figcaption></figure>

If a rule is set, then **the Field A** will have a list of values that are controlled by the value from **the Field B** as per defined rule.

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2F3clS26eSlGCgSAXVWYa8%2Fimage.png?alt=media&#x26;token=e2b2f39c-d888-47f8-8484-42b055b64daf" alt=""><figcaption></figcaption></figure>

You can define multiple restrictions for different combinations of fields.

To set up a Restriction rule, do the following steps:

* Create single select fields in the [template](https://docs.aqua-cloud.io/documentation/project-configuration/project-template-configuration-fields) for your item type if you don't plan to use default only.
* Select project and navigate to the **Field rules**

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2F8eLNYT2DJTKu1zltai2O%2Fimage.png?alt=media&#x26;token=854d1db6-974d-497d-9082-cd207edb17da" alt=""><figcaption></figcaption></figure>

* Select item type and then a field that will be affected

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2F5sqpJNpRzkMzo4T8xMcZ%2Fimage.png?alt=media&#x26;token=05e0f045-4b75-475a-98f2-1ac7d5f8e1eb" alt=""><figcaption></figcaption></figure>

* Then controlling field

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2Fk9UMQYihBpfRgVqR066J%2Fimage.png?alt=media&#x26;token=5f58d600-d3a2-4a01-99fb-4bb4c06c0980" alt=""><figcaption></figcaption></figure>

* Then select the value from the controlling field

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2FfvoFf1D6b0h5kM2q6ahR%2Fimage.png?alt=media&#x26;token=1bdc04f0-3974-407e-9af0-e51cbb43ae55" alt=""><figcaption></figcaption></figure>

* Then values for the affected field that will be shown

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2FPrcCgoh9xZ9GcU4lJPtc%2Fimage.png?alt=media&#x26;token=fd0b8c7d-cc02-43d3-95c7-632191eebd34" alt=""><figcaption></figcaption></figure>

* Save changes

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2F9t2WNLwGWuw0GUlxMv96%2Fimage.png?alt=media&#x26;token=e87209e0-78ed-4b20-839a-0f1fa70c0cb9" alt=""><figcaption></figcaption></figure>

### **Actions**

Actions define how a field should behave based on the value selected in another field.

The are following action rules that be can defined:

* Set value
* Required
* Read-only
* Highlight
* Visible/Hidden

**For example:**

* If the **Field A** value equals *Item 1,* then **the Field B** will be **Required**\
  ![](https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2FGnyWCptHWFKh2uv9Vwo6%2Fimage.png?alt=media\&token=8a0cb7f6-b003-412c-a3e4-385a0846a8f8)

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2FyWn6r9mbAcNMYljToFG7%2Fimage.png?alt=media&#x26;token=103acbb1-271c-43ab-be88-ca2f41c5ede1" alt=""><figcaption></figcaption></figure>

This allows you to dynamically adjust forms depending on context.

**Actions** set up

* Go to Project Configuration → Field Rules.
* Select the item and then the controlling field (the field whose value triggers the rule).
* The select the rule ‘Actions’.
* Once you select ‘Actions’, then click 'Add new action’’ and select the controlling from the dropdown that will affect another field.

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2FIvB9r4NZpTsgBubKrrG6%2Fimage.png?alt=media&#x26;token=55e7d130-cb10-4432-b701-16e0d0a36ea8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2FHnriUrOaTWHHtspEkwqc%2Fimage.png?alt=media&#x26;token=6119f4f1-2092-4c7f-8986-ff5e0a266a95" alt=""><figcaption></figcaption></figure>

* Then select the affected field.

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2FaQReR93oDZVeM3hI1tlZ%2Fimage.png?alt=media&#x26;token=aef48d9c-8075-48be-bb9e-00ab489b999f" alt=""><figcaption></figcaption></figure>

* Define the desired logic and behavior by checking one or multiple checkboxes: **set value, required, read-only, highlight, visible.**

<figure><img src="https://3920520305-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyZbW8vbNs5hz8x57emJJ%2Fuploads%2F0IuKl6qTLNoRkvTfa30P%2Fimage.png?alt=media&#x26;token=21e77ba1-7120-4b83-8d42-883264ea8b6e" alt=""><figcaption></figcaption></figure>

* Click **Save** to apply changes.

{% hint style="info" %}
Please note:

* When you select ‘Set value’, you can define a default value that will always be applied.
* The ‘Visible’ option is enabled by default. If you want to hide the field, simply uncheck it.
* The ‘Visible’ option is automatically checked whenever a field is set as required.
  {% endhint %}

Furthermore, field values from single-select fields with shared value sets can be set automatically when creating dependent items or creating defects from test executions.&#x20;
