+ Start a Discussion
jaysree Ajaysree A 

I have 10 users in one profile. I want to write a validation rule i.e applicable for 5 users only. How to acheive this. Please help!!!!

Anupama SamantroyAnupama Samantroy
Hi Jayshree,

You can use custom permissions. You can assign then to the users and then include them in the validation rule to fire only for those users who have the custom permission.
Please find more information at link https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/custom_perms_overview.htm

nagendra 6989nagendra 6989

Please find the below explanatiion matching your requirement criteria.

When you have multiple users in one profile and you want to write a validation rule which should be applicable only for some users then you can use custom permissions.

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.

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. For example, you can define access checks in Apex that make a button on a Visualforce page available only if a user has the appropriate custom permission.

So by using custom permissions you can just provide access to the selected users and the validation rule which is written will be fired only for those userss

You can query custom permissions in these ways

To determine which users have access to a specific custom permission, use Salesforce Object Query Language (SOQL) with the SetupEntityAccess and CustomPermission sObjects.
To determine what custom permissions users have when they authenticate in a connected app, reference the user's Identity URL, which Salesforce provides along with the access token for the connected app.

How to create a custom permission 

1)From Setup, enter Custom Permissions in the Quick Find box, then select Custom Permissions.
2)Click New.
3)Enter the permission information:
    Label—the permission label that appears in permission sets
    Name—the unique name that’s used by the API and managed packages
    Description—optionally, a description that explains what functions the permission grants access to, such as “Approve time-off requests.”
    Connected App—optionally, the connected app that’s associated with this permission
4)Click Save.

Please let us know if this helps you..................

Best Regards