bypass automation using custom permission

Bypass automations using a Custom Permission

What is a Custom Permission


A custom permission is a specific attribute added to a Permission Set. This attribute allows you to apply a specific logic to any user being assigned this permission set.

For instance, let’s assume you have some data migration activities planned soon in your project and you want a configurable way to bypass some of your automations. The idea is to have a dedicated permission set being assigned a custom permission. Assign this permission set to the user executing the dataload.

See below how technically the custom permission can be checked depending on the type of automation, including Apex code, Flow and Validation Rules.


Reading a Custom Permission from Apex


Checking for custom permission in Apex code is very straighforward. Use the FeatureManagement class and the checkPermission method.

Boolean hasCustomPermission = FeatureManagement.checkPermission('<custom_permission_api_name>');

if (hasCustomPermission) {
    // Execute specific logic, or bypass it
}

Reading a Custom Permission from Flows


To read custom permission from a Flow, just look for it in a Decision component, through the ressource $Permission. Example below.


Reading a Custom Permission from Validation Rules


Use system function to read the custom permission directly!


Have you found this interesting? Please share!


Leave a Comment

Your email address will not be published. Required fields are marked *