# Setting Up Object Relationships With Controlling Fields

Controlling fields take advantage of parent-child relationships and many-to-many relationships to provide easier, less error-prone data entry when creating or editing object records. This article explains, through examples, how to configure an object's fields to support controlling field behavior.

## Example: Referenced Parent-Child Relationships on the Milestone Object

When Elaine creates a new milestone, she sees fields to select _Study_, _Study Country_, and _Study Site_. At first, the _Study Country_ and _Study Site_ fields are greyed out. Once she selects the correct _Study_, the _Study Country_ field becomes editable and allows her to choose from the _Study Country_ records **that belong to the selected _Study_**. She can't choose an invalid _Study Country_ because the list is limited to valid options. She sees the same behavior for _Study Site_, which is controlled by the _Study Country_ selection.

### How to Configure

First, you need to ensure that the _Study_, _Study Country_, and _Study Site_ objects are in parent-child relationships, with _Study_ as the top level and _Study Site_ as the lowest level.

Once you've verified that the object hierarchy is correct, you can create the fields that Elaine saw when she created a new milestone. Go into the _Milestone_ object configuration and add new fields with the _Object_ type. By creating these fields, you're creating new reference relationships:

  * Milestone to Study
  * Milestone to Study Country
  * Milestone to Study Site

The first field you create must reference the _Study_ object because that is the highest-level object in the parent-child hierarchy and therefore does not have a controlling field. You have to create the highest level first because the field must already exist in order to control another field.

The second field you create should reference _Study Country_. Once you've selected _Study Country_ as the referenced object, Vault displays a new option: **Controlling Field**. When Elaine is editing the _Study Country_ field on her milestone, the controlling field specified here will determine what options are available to select. The controlling field must reference a field related to the parent object. In this example, _Study_ is the only option. When you create the _Study Site_ field, _Study Country_ will be the controlling field.

## Example: Referenced Many-to-Many Relationships on the Marketing Campaign Object

In Marcus' Vault, _Product_ and _Country_ are in a many-to-many relationship. This allows Admins to indicate the countries where a product is available by creating a relationship between the _Country_ records and the _Product_ records. For example, Nyaxa is available in Canada, Spain, the United States, the United Kingdom, Germany, and France, but VeevaProm is not available in France and Germany.

When Marcus creates a new marketing campaign, he sees fields to select _Product_ and _Product Country_. At first, the _Product Country_ field is greyed out. Once he selects the correct _Product_, the _Product Country_ field becomes editable and allows him to choose from the _Product Country_ records **that belong to the selected _Product_**. He can't choose an invalid country because the list is limited to valid options.

### How to Configure

First, you need to ensure that there is a many-to-many relationship where the _Product Country_ object's parents are _Product_ and _Country_.

Once you've verified that the object setup is correct, you can create the fields that Marcus saw when he created a new campaign. Go into the _Marketing Campaign_ object configuration and add new fields with the _Object_ type. By creating these fields, you're creating new reference relationships:

  * Marketing Campaign to Product
  * Marketing Campaign to Product Country

The first field you create must reference the _Product_ object because that will be the controlling selection for the _Product Country_ field. You have to create the controlling field first because the field must already exist in order control another field.

The second field you create should reference _Product Country_. Once you've selected this as the referenced object, Vault displays a new option: **Controlling Field**. When Marcus is editing the _Product Country_ field on his campaign, the controlling field specified here will determine what options are available to select. The controlling field must reference a field related to the parent object.

When setting up controlling fields for objects in a many-to-many relationship, the first (controlling) field must reference one of the two parent objects (_Product_ or _Country_) and the second (controlled) field must reference the relational child object (_Product Country_). If you wanted to, you could also set up these fields so that Marcus selects a country and then sees a list of products available for that country. In that setup, the first field you create would reference the _Country_ object and the second, like before, would reference the _Product Country_ object.
