> For the complete documentation index, see [llms.txt](https://docs.yansalabs.com/simple-data-separation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yansalabs.com/simple-data-separation/technical-docs/separation-rules/defined-relationships.md).

# Defined Relationships

{% hint style="info" %}
Defined Relationships allow you to create relationships between your users and your data that may not exist by default in ServiceNow.
{% endhint %}

<figure><img src="/files/VVmuQm8kJg9DjueYFdzu" alt=""><figcaption><p>Defined Relationship</p></figcaption></figure>

By default, ServiceNow recognizes a limited set of relationships for a user as part of their session. These are

* Groups
* Department
* Company
* Location

However, many organizations may need additional relationships such as *Business Unit*, *Agency*, etc. In these cases, you can create a Defined Relationship.

To create a Defined Relationship:

1. Click 'New' on the **Defined Relationship** related list at bottom of the **Separation Rule** form
2. Provide a **Name** for the Defined Relationship
3. Set the **Field** on the Separation Rule target table where this relationship exists. For the example of *Business Unit*, the field would likely be called 'Business unit'. This setting lets Simple Data Separation where to apply the relationship you create, and allows you to maintain the convenience of auto-code-completion when using that field on your Separation Rule.
4. Create a **Script** to gather the value for this relationship for the logged-in user. The return value of the script should be an array of values for which the logged-in user is a 'member'. For the example of *Business Unit*, the script could be as simple as

```javascript
answer = [user.getValue('u_business_unit'];
```

Once the Defined Relationship exists, you can use the selected field as a **Separator field** on your Separation Rule just as you would use any normally supported field.

{% hint style="info" %}
*During development & testing, it is recommended to disable session caching in Yansa Simple Data Separation -> General Settings. Otherwise, it is necessary to logout & login to begin a new user session so that the Defined Relationship value will be recalculated between each update.*
{% endhint %}

{% hint style="info" %}
In addition to creating new relationships, **Defined Relationships** can be used to augment existing relationships. If you'd like to customize the way Simple Separation gathers a user's *Department* beyond ServiceNow's default logic, simply create a Defined  Relationship against the 'Department' field on the target record. Your Defined Relationship will override ServiceNow's default behavior.
{% endhint %}
