> 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.yansalabs.com/simple-data-separation/technical-docs/separation-rules/defined-relationships.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
