Custom Permissions provide a simple and flexible way to control access to Lightning Web Components (LWCs) without modifying profiles or creating multiple Lightning pages. By combining a Custom Permission with Dynamic Component Visibility in Lightning App Builder, you can ensure that a component is displayed only to users who have the required permission.
This article explains how to create a Custom Permission, assign it to users through a Permission Set, and configure a Lightning record page so that the Lightning Web Component is visible only to authorized users.
Details given below
1. Create the Custom Permission
Go to:
Setup → Custom Permissions → New
Example:
- Label:
View Time Tracker Component - API Name:
View_Time_Tracker_Component
2. Assign it through a Permission Set
Create or open a Permission Set, then go to:
Custom Permissions → Edit
Add View Time Tracker Component, save it, and assign the Permission Set to the required users.
3. Configure component visibility
Open the Lightning page in Lightning App Builder:
- Select the LWC.
- Open Set Component Visibility.
- Click Add Filter.
- Select Permissions → Custom Permission.
- Choose
View Time Tracker Component. - Set the value to
True. - Save and activate the page.