---
title: "Restrict which records a role can see"
site: admin
version: 1.11
versions: "all"
url: https://docs-new.servicely.ai/admin/1.11/access/table-record-restrictions/
type: task
application: platform
last_updated: 2026-10-18
commit: c05803eee2ce
---


Use a table record restriction when users may read a table but should see only some of its records. This task is for administrators. Permissions decide which tables and fields a user can use, and a restriction narrows the records within a table.

## Before you begin

- You need `administrator`.
- Decide which role the restriction applies to. You can use an existing role or create one under **Administration → Permissions & Security → Roles**.
- Make sure a permission lets that role read the table. See [Permissions: table, field and transition](page:access/permissions).

## Steps

When anyone queries a table, Servicely looks for active table record restrictions on it. This includes opening a record from a link. Each restriction's **Query** script runs. If the script sets `answer` to a query, Servicely adds that query to the user's own. If the script does not set `answer`, nothing is added.

<Steps>
  <Step>
    Go to **Administration → Permissions & Security → Table record restrictions** and select **New**.
  </Step>
  <Step>
    Enter a **Name** and a **Description**, and select the **Table**.
  </Step>
  <Step>
    Write the **Query** script. Check the user's roles or groups, and set `answer` only for users who should be restricted. See the example below.
  </Step>
  <Step>
    Turn on **Active** and save.
  </Step>
  <Step>
    Give the role to the users who should be restricted, directly or through a group.
  </Step>
  <Step>
    Impersonate one of those users and open the table to confirm what they see. See [Impersonate a user](page:access/impersonate-a-user).
  </Step>
</Steps>

| Field | Required | What to enter |
| --- | --- | --- |
| Name | Yes | A name that says what is restricted, for example "Incident - Record visibility restrictions". |
| Description | Yes | What the restriction does and for whom. |
| Table | Yes | The table to restrict. |
| Query | Yes | A script that sets `answer` to the query to add. |
| Active | No | When on, the restriction runs on every query of the table. |
| Order | No | The order among restrictions on the same table. |

### Example query

The ITSM application ships this restriction on Incident. A user who can read incidents but does not hold `itsm_agent` sees only incidents where they are the **Requestor** or the **Requested for**.

```javascript
if (!user.hasRole("itsm_agent")) {
    answer = OR(
        EQUAL("Requestor", user.getID()),
        EQUAL("RequestedFor", user.getID())
    );
}
```

## Result

Users the script restricts see only the matching records, wherever the table is queried, including direct links. Other users see the table as before. A restriction adds to permissions and tenancy, and never widens what a user can see.

## Related

- [Permissions: table, field and transition](page:access/permissions)
- [Roles](page:access/roles)
- [Multi-tenancy](page:access/multi-tenancy)
