Custom Permission - Salesforce Admin Concepts | Salesforce Funda

Custom Permissions let you define access checks that can be assigned to users via permission sets or profiles, similar to how you assign user permissions and other access settings




Example like :-

use it to provide access to processes,
use to involve in or bypass validation rules, etc

To check in apex :-

  
Boolean hasCustompermission = FeatureManagement.checkPermission('your_custom_permission_api_name');


Custom Permission User Case :- we need to bypass validation rule using Custom Permission for some user


Step 1 :- Go to the Setup Home, Quick find box Search for Custom Permission




Step 2 :- Click on Custom Permission, Click on New Button 




Step 3 :- Fill the below details in the field values 
  
         Lable :- Bypass Account Validation
Name  :- Bypass_Account_Validation
Description :- give accordingly 
Connected App :- leave blank 
 
click on Save 




Step 4 :- again go to the Setup Quick find box search for Permission set, click and Open it 




Step 5 :- click on new button, and fill the below details 

         Label :- Custom Permission set
         API Name :- Custom_Permission_Set
         Description :- give accordingly 
click on save




Step 6 :- Now go to the Custom Permission APP section "Custom Permission", click  on that and open it.




Step 7 :- Click on Edit button 


Step 8 :- select the Custom Permission we created and click on save 




Step 9 :- now click on Manage Assignments 




Step 10 :- click on Add Assignment




Step 11 :- select the User which you want to assign, click on Next




Step 12 :- click on Assign 




Step 13 :- click on Done

Step 14 :- now go to the Object Manager - Select any Object in our Case, we select Account Object go to the Validation Rule of the Account Object 

Step 15 :- Click on New button in Validation Page in Account Object 




Step 16 :- Give the rule name and update this validation "AND(ISBLANK(Phone),ISPICKVAL( Industry , 'Media'))" we checking Phone field,
        when Industry has Media value if phone is null value give error




Step 17:- go to the Account create new record with Industry value as Media and Phone value as null and see the validation fire 

Step 18:- Now we can use Custom Permission to over rule the validation rule for some profile, now go to the Validation rule and use this 
       "AND(NOT($Permission.Bypass_Account_Validation), ISBLANK(Phone),ISPICKVAL( Industry , 'Media'))"


       
Step 19 :- now go and check creating new record with industry as Media and Phone as null, you able to create new Record, this is the way you can bypass validation rule