---
schema_version: "1"
id: 8c65847acad093c75c2e4fa9409ff38f08b160e184041f6415227bb1dc70b301
title: WITH RecordVisibilityContext
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-soql-sosl/guides/soql-sosl/sforce-api-calls-soql-select-with-recordvisibilitycontext.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-select-with-recordvisibilitycontext.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: abe759c854c39ebb050a3c02b7695a4490633cb07a3f16c182e684177b92e1fe
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# WITH RecordVisibilityContext

You can use `RecordVisibilityContext` to filter `WITH` clauses to query the attributes that determine the visibility of one or more records. This feature is available in API version 48.0 and later.

The following fields can be used as parameters:

| Field                    | Description                                                                                                                                                                                                         | Default                                          |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| `maxDescriptorPerRecord` | The maximum number of descriptors to return per record. If the actual number of descriptors for a specific record exceeds that value, then a "tooManyDescriptors" visibility attribute is returned for that record. | orgs with CRM Analytics: 150, or other orgs: 400 |
| `supportsDomains`        | Whether the Visibility Service is allowed to generate "domain" visibility attributes.                                                                                                                               | true                                             |
| `supportsDelegates`      | Whether the Visibility Service is allowed to generate "delegate" visibility attributes.                                                                                                                             | true                                             |

For example:

```soql
SELECT Id, RecordVisibility.VisibilityAttribute FROM Account WHERE Id = 'xxx'
   WITH RecordVisibilityContext (maxDescriptorPerRecord=100, supportsDomains=true, supportsDelegates=true)
```

```soql
SELECT recordId, VisibilityAttribute FROM RecordVisibility WHERE recordId = 'xxx'
   WITH RecordVisibilityContext (maxDescriptorPerRecord=100, supportsDomains=true, supportsDelegates=true)
```

At least one field is necessary. This query is _invalid_:

```soql
SELECT Id, RecordVisibility.VisibilityAttribute FROM Account WHERE Id = 'xxx'
   WITH RecordVisibilityContext
```

This query is valid:

```soql
SELECT Id, RecordVisibility.VisibilityAttribute FROM Account WHERE Id = 'xxx'
   WITH RecordVisibilityContext (maxDescriptorPerRecord=100)

```

For more information, see [RecordVisibility](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_recordvisibility.htm#!) in the _Object Reference_.
