In Salesforce, many
features require access checks that specify which users can access certain
functions. Permission set and profiles settings include built-in access
settings for many entities, like objects, fields, tabs, and Visualforce pages.
However, permission sets and profiles don’t include access for some custom
processes and apps.
Challenge 1 :
Suppose We have an object
“Product Complaint” and it has filed
like below,
1.
Status [Open/ Closed/ Other] è Pick list filed.
2.
Reason For Other è Text
Now create a validation rule so that if Status is
selected as “Other” and if user was not entered any value for “Reason For Other” field, then an warning/error/validation message will
be thrown as “Please enter reason to
select other”.
Now our aim is that this
validation rule will be fire for every users except the user belongs to System
Admin profile. That mean
user with system admin profile will able to save any PC record with status
value as “Other” and no value in “Reason
For Other” filed.
Solution:
1. Create a custom permission.
2. Assign it to System Admin Profile.
3. Update the validation rule.
Now user with System
Admin profile can create PC record with “Other” status – without entering “Reason For Other” value. But other profile user will get the validation
message.
Challenge 2 :
Now if we want this
validation in user level i.e.
some System Admin user will face this validation rule and some not.
Solution:
1. Remove “Custom Permission” form System Admin
Profile.
2. Create a permission
set (Named it same as custom permission).
3. Click on “Manage Assignments” button to assign the user who can
use this permission set.
4. Now click on the
“Custom Permissions” link to assign custom permission to “Permission Set”.
5. Now try to test the validation rule for 2 System Admin Users,
one who is assigned in Permission Set and one who is not assigned.
Note: We can
also use custom permission in VISUALFORCE page. Like some render condition.
Syntax is look
like below,
(Not($Permission. Can_Set_PC_Status_to_Other))