Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Custom Permissions entry
How-to guide

How to use Custom Permissions for code-gated business logic

The pattern: identify the business-logic gate, create the Custom Permission, reference it in code, assign through a permission set named after the role. The cost is one Custom Permission record plus one code reference; the benefit is admin-managed access without redeploying code for assignment changes.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated May 18, 2026

The pattern: identify the business-logic gate, create the Custom Permission, reference it in code, assign through a permission set named after the role. The cost is one Custom Permission record plus one code reference; the benefit is admin-managed access without redeploying code for assignment changes.

  1. Identify the business-logic gate that needs admin-controlled access

    A validation rule that should bypass for certain users, a Flow that should branch for senior approvers, an Apex method that should run for specific roles. The candidate is any access decision currently hardcoded.

  2. Create the Custom Permission

    Setup, Custom Permissions, New. Name per convention (purpose-driven: Bypass_Discount_Validation, Senior_Approver, Access_Beta_Feature).

  3. Reference the Custom Permission in code

    Apex: FeatureManagement.checkPermission. LWC: import from @salesforce/customPermission. Flow: $Permission reference. Validation Rule: $Permission reference.

  4. Create or extend a permission set with the Custom Permission

    Name the permission set after the business role (Renewal Manager, Senior Approver). Include the Custom Permission in the set's System Permissions, Custom Permissions section.

  5. Assign the permission set to the right user population

    Bulk assign via Setup or via a Flow that triggers on user attribute changes. Document the assignment criteria.

  6. Test with users in and out of the assigned population

    Confirm the code path fires for assigned users and skips for unassigned. Sandbox first; production behavior should match.

  7. Document the Custom Permission and code references

    Name, purpose, code references, permission sets that include it. The inventory is what saves future admins from forensics.

Custom Permission nameremember

Purpose-driven, convention-based. The API identifier code references.

Permission set assignmentremember

Permission set named after business role; includes one or more related Custom Permissions.

Code reference methodremember

Apex FeatureManagement.checkPermission, LWC import, Flow $Permission, Validation Rule $Permission.

Inventory documentationremember

Name, purpose, code references, holding permission sets. Required for maintainability.

Sandbox test coverageremember

Test both with and without the permission to confirm the code branches correctly.

Gotchas
  • Custom Permissions assigned through profiles work but break the modern permission-set-first pattern. Default to permission-set assignment.
  • Without assignment, no user holds the Custom Permission. Creating the Custom Permission and forgetting the permission set assignment is a common omission.
  • Code that checks a Custom Permission and finds nobody has it executes the no-permission branch. Test both branches; the unassigned branch needs to be correct, not just the assigned one.
  • Custom Permissions accumulate without documentation. The inventory is the discipline that prevents permission sprawl.
  • Pick platform-native permissions when they exist. Custom Permissions are the right tool when no platform construct fits; using them for things the platform already supports adds unnecessary configuration.

See the full Custom Permissions entry

Custom Permissions includes the definition, worked example, deep dive, related terms, and a quiz.