CustomPermission defines a named permission that grants access to a custom feature. The permission definition, the configuration that grants it, and the code or configuration that checks it are separate concerns. Deploying the definition alone does not identify which users have access.
A custom permission is not a permission set. A permission set can enable a custom permission, while Apex or a Lightning web component (LWC) can check that permission. Importing or checking a permission-set name is not a substitute for checking the custom permission.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
Inherited metadata component identity. This is distinct from the runtime CustomPermission record ID. |
label |
Required display label. Maximum length: 80 characters. |
description |
Explains the feature or access boundary represented by the permission. Maximum length: 255 characters. |
connectedApp |
Names an associated ConnectedApp. Maximum length: 80 characters. The association does not grant users access or establish ownership or deployment order. |
isLicensed |
Required and read-only. true indicates that the appropriate Salesforce license is required before accessing the permission; false indicates that it is not. This is a licensing indicator, not a writable access switch. |
requiredPermission |
Repeated structure declaring prerequisites between custom permissions. These entries constrain enablement; they are not user assignments. |
customPermission |
Required within each requiredPermission entry. Names the other custom permission involved in the dependency. |
dependency |
Required within each requiredPermission entry. true requires the named permission to be enabled when the parent permission is enabled. false imposes no such requirement; it does not deny the named permission. |
Behavior and Constraints
Setup-object access is separate from feature access. Access to the CustomPermission setup object requires at least one of these permissions:
- View Setup and Configuration
- Manage Session Permission Set Activations
- Assign Permission Sets
These permissions allow access to the setup object. They do not replace the custom feature's own permission check.
Dependencies constrain enablement. If permission A declares permission B with dependency=true, B must be enabled when A is enabled. B can itself require another permission, creating a multistep dependency chain. When changing a permission, consider both its prerequisites and other permissions that require it. A dependency declaration does not assign either permission to a user.
Licensing does not grant access. Read isLicensed as an indication of whether an appropriate Salesforce license is required. It is read-only and must not be treated as a switch for enabling a permission for users.
Check the running user in Apex. Community guidance uses FeatureManagement.checkPermission('Permission_API_Name'). The argument identifies the custom permission, not a permission set. This checks the running user; it is not a lookup for an arbitrary user. See the running-user check example.
Use assignment records for explicit permission-set audits. A reported query pattern follows this runtime data path:
- Locate the
CustomPermissionrecord byDeveloperName, filtering byNamespacePrefixwhere needed. - Match
CustomPermission.IdtoSetupEntityAccess.SetupEntityId. - Follow
SetupEntityAccess.ParentIdtoPermissionSet.Id. - Use
PermissionSetAssignmentto find users assigned those permission sets.
These runtime records and IDs are distinct from the metadata definition and its fullName. This is an assignment-audit pattern, not a complete calculation of every user's effective access. See the assignment query example.
Deployment and Retrieval
CustomPermission components use the .customPermission suffix and are stored in the customPermissions folder. The type supports the * wildcard in package.xml, the manifest that selects metadata components for deployment or retrieval. Use CustomPermission as the manifest type name.
A manifest can include the permission definitions, an associated ConnectedApp, and the PermissionSet components that enable the permissions. These are separate components. Neither their display order in a manifest example nor the connectedApp association establishes a mandatory deployment sequence.
Deploying a permission definition does not establish user assignments. For a grant through a permission set, the custom permission must be enabled in that permission set and the permission set assigned to the user. Review requiredPermission entries as enablement constraints, including prerequisites reached through other custom permissions.
Package installation can produce different observed access from deployment of the same component definitions. Community reports describe custom permissions becoming available through profile grants based on the installation access selection, even when the packaged permission set was not explicitly assigned. An unexpected true result after installation therefore calls for examining profile grants and the installation access selection, not just permission-set assignments.
Relationships
Impact analysis includes permission configuration, audience configuration, dependent custom permissions, and code consumers. An LWC can consume a custom permission through an import embedded in its code rather than through a dedicated structured reference field. The connectedApp association names an app; it does not describe user grants.
References
-
ConnectedApp:connectedApp. -
CustomPermission:customPermissionwithinrequiredPermission.
Referenced By
-
Audience:permissionName. -
CustomPermission:customPermissionwithinrequiredPermission. -
LightningWebComponent: references embedded infiledata. -
MutingPermissionSet:nameentries in custom-permission configuration. -
PermissionSet:nameentries in custom-permission configuration.
Reported Issues
-
An LWC check can return
undefineddespite a successful Apex check when it uses the wrong import module. In a 2022 report,FeatureManagement.checkPermissionreturnedtrue, but the component imported the custom permission through@salesforce/userPermission/Permission_API_Name. The accepted correction was@salesforce/customPermission/Permission_API_Name. See the import-module correction. -
A custom-permission import does not check permission-set membership. In a 2023 discussion about
undefinedresults, the accepted guidance was to enable the custom permission in the permission set and assign that permission set to the user. Passing a permission-set name to a permission import was not a membership check. See the grant-path explanation. - Installing a managed package for all users was reported to enable the custom permission on all profiles. In the 2017 case, the permission was also included in a permission set, but choosing Install for All Users still produced profile grants. The accepted answer recommended selecting Install for Admins or Install for Specific Profiles when the intention was to assign the permission set separately afterward. See the managed-package installation report.
-
Permission checks were reported to return
trueafter installation without assignment of the packaged permission set. A 2024 second-generation managed package, or 2GP, discussion reported this for administrators with Customize Application after Install for Admins Only, and for users after Install for All Users. The original report observed different results when deploying the code instead of installing the package. This is a reported installation effect, not evidence that administrators universally bypass custom permission checks. See the 2GP access-check report.
Common Questions
How do I retrieve all custom permissions?
Use the CustomPermission type with * as the member in package.xml. Components use the .customPermission suffix in the customPermissions folder.
Does deploying a CustomPermission give users access?
The definition alone does not establish user access. For a permission-set grant, enable the custom permission in the permission set and assign the permission set to the user. Code or configuration must check the permission to control the custom feature.
Why is my LWC custom permission undefined when Apex returns true?
A reported cause was importing a custom permission through @salesforce/userPermission instead of @salesforce/customPermission/Permission_API_Name. Also distinguish the custom permission's API name from a permission-set name and verify the grant path.
How do I find users assigned a custom permission?
For explicit permission-set assignments, locate the runtime CustomPermission by DeveloperName and namespace where needed, then follow SetupEntityAccess to PermissionSet and PermissionSetAssignment. This audit pattern does not calculate every source of effective access. For the running user, community guidance uses FeatureManagement.checkPermission.
Why does a custom permission return true after package installation without a permission-set assignment?
Reported package-installation behavior includes profile grants based on Install for All Users or Install for Admins Only. Examine those grants and the installation access selection rather than assuming that access can come only from the packaged permission set.