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
  • 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:

SELECT Id, RecordVisibility.VisibilityAttribute FROM Account WHERE Id = 'xxx'
   WITH RecordVisibilityContext (maxDescriptorPerRecord=100, supportsDomains=true, supportsDelegates=true)
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:

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

This query is valid:

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

For more information, see RecordVisibility in the Object Reference.