How do Permission Sets provide flexible, modular privilege extensions without requiring profile duplication?
Answer
Basics: A permission set is a collection of settings (object permissions, field permissions, system permissions, app/tab visibility, Apex class access, custom permissions, flows) that you assign to one or many users. They are purely additive: they can grant, never take away.
How it works:
- Setup > Permission Sets > New; optionally choose a license (blank works for users of any license, or pick a license to unlock license-specific permissions).
- Configure Object Settings, Field Permissions, System Permissions, Apex Class Access, App Assignments, etc.
- Manage Assignments > Add users, or assign through API/Flow.
- Effective access = profile permissions plus all assigned permission sets (union).
- Permission Set Licenses unlock features such as add-ons.
Advanced / deep dive: Design permission sets around capabilities ("Can Approve Discounts", "Export Reports") rather than people, keeping them small and reusable, and bundle them in Permission Set Groups. Session-based permission sets activate only during a session after something like a step-up authentication or flow event, supporting least privilege. Assignment expiration dates are supported in recent releases (verify availability for your org). Because permissions are additive, to remove access you must remove the permission set or change the profile; a Muting Permission Set exists only inside Permission Set Groups. Track in version control; deploy with Metadata API (PermissionSet). Assign in bulk with Apex or Flow, and mind the user license compatibility: a permission set with a license can only go to users with a matching license.
Code / config example:
// Assign a permission set to many users (bulk-safe, skip existing assignments)
[SELECT Id FROM PermissionSet LIMIT ].Id;
Set<Id> already = <Id>();
(PermissionSetAssignment a : [SELECT AssigneeId FROM PermissionSetAssignment
:psId AND AssigneeId IN :userIds]) already.add(a.AssigneeId);
List<PermissionSetAssignment> toInsert = <PermissionSetAssignment>();
(Id uid : userIds) (!already.contains(uid)) toInsert.add( (AssigneeId = uid, PermissionSetId = psId));
insert toInsert;