+ Start a Discussion
Starmap3Starmap3 

Validation rule with custom permission (multiple profiles and record types)

Hi All,

I need a validation rule for a custom object with multiple record types.  Only 2 custom profiles can move a custom stage field to a value of "Complete" (regardless of record type) and 1 custom profile can move the same custom stage field to a value of "Complete" for only 1 of the record types (there are 10+).

I wanted to try to leverage a custom permission at the profile level rather than have a large block of hard coded profile ids and record type names so I started with:

ISPICKVAL(Custom_Stage_Field__c , "Complete") && 
NOT($Permission.Custom_Permission_Name)

This is fine for the first use cases (2 profiles regardless of record type) where the custom permission is enabled however the third custom profile should only move the custom stage field to complete for 1 specific record type, not all. I am sure this just needs to be updated with an OR statement for the last profile and the specific record type but I am not having any luck.  Any ideas would be great!  If anyone needs more info let me know.  Thanks!

 
Best Answer chosen by Starmap3
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Custom Permissions are defined on User or Profile level so if the profile has access to all record types then you won't be able to restrict it by a custom permission. So, either you can use the profile Ids and record type ids in the validation OR you can create a Hierarchy Custom Setting and create checkboxes for different scenarios and then use them in your validation rule.

All Answers

SalesFORCE_enFORCErSalesFORCE_enFORCEr
Custom Permissions are defined on User or Profile level so if the profile has access to all record types then you won't be able to restrict it by a custom permission. So, either you can use the profile Ids and record type ids in the validation OR you can create a Hierarchy Custom Setting and create checkboxes for different scenarios and then use them in your validation rule.
This was selected as the best answer
Starmap3Starmap3
Thank you, your feedback was helpful and let me to this example.  I had seen it before but didn't bookmark it.  Thanks!
https://www.verticalcoder.com/2012/07/26/custom-settings/