USING SCOPE
The optional USING SCOPE clause of a SOQL query
returns records within a specified scope. For example, you can limit the records to return
only objects that the user owns or only records in the user’s territory.
With API version 32.0 and later, you can use USING SCOPE to limit the results of a query to a specified filterScope.
[USING SCOPE filterScope]
filterScope can take one of many enumeration values. To get a list of scopes supported by an object, call describeSObject() for SOAP API or
sObject Describe for REST API.
In the supportedScopes section of the object’s description, the name shows the name of the scope and the
label shows an explanation of that scope. This example shows the description of the Account
object.
"supportedScopes" : [
{
"label" : "All accounts",
"name" : "everything"
},
{
"label" : "My accounts",
"name" : "mine"
},
{
"label" : "My team's accounts",
"name" : "team"
}
],
This table lists examples of enumeration values that filterScope can take.
Scope | Description |
---|---|
delegated | Filter for records delegated to another user for action. For example, a query could filter for only delegated Task records. |
everything | Filter for all records. |
mine | Filter for records owned by the user running the query. |
mine_and_my_groups | Filter for records assigned to the user running the query and the user’s queues. If a user is assigned to a queue, the user can access records in the queue. This filter applies only to the ProcessInstanceWorkItem object. |
my_territory | Filter for records in the territory of the user running the query. This option is available if territory management is enabled for your organization. |
my_team_territory | Filter for records in the territory of the team of the user running the query. This option is available if territory management is enabled for your organization. |
scopingRule | Filter for records based on the applicable scoping rule. This option is available if an admin has activated at least one scoping rule on the object that you’re querying. |
team | Filter for records assigned to a team, such as an Account team. |