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:

FieldDescriptionDefault
maxDescriptorPerRecordThe 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
supportsDomainsWhether the Visibility Service is allowed to generate “domain” visibility attributes.true
supportsDelegatesWhether the Visibility Service is allowed to generate “delegate” visibility attributes.true

For example:

1SELECT Id, RecordVisibility.VisibilityAttribute FROM Account WHERE Id = 'xxx'
2   WITH RecordVisibilityContext (maxDescriptorPerRecord=100, supportsDomains=true, supportsDelegates=true)
1SELECT recordId, VisibilityAttribute FROM RecordVisibility WHERE recordId = 'xxx'
2   WITH RecordVisibilityContext (maxDescriptorPerRecord=100, supportsDomains=true, supportsDelegates=true)

At least one field is necessary. This query is invalid:

1SELECT Id, RecordVisibility.VisibilityAttribute FROM Account WHERE Id = 'xxx'
2   WITH RecordVisibilityContext

This query is valid:

1SELECT Id, RecordVisibility.VisibilityAttribute FROM Account WHERE Id = 'xxx'
2   WITH RecordVisibilityContext (maxDescriptorPerRecord=100)

For more information, see RecordVisibility in the Object Reference.