OOTB31: How to Use Custom Permission in Apex Trigger in 2025 || Secure Product Updates
Автор: Salesforce AI Champions
Загружено: 2025-12-13
Просмотров: 15
Описание:
In this Salesforce tutorial, you’ll learn how to control product deactivation using Custom Permissions inside an Apex Trigger.
This approach lets you protect critical data by ensuring that only users with a specific custom permission can deactivate a Product record.
We’ll walk through:
• Creating a Custom Permission
• Adding it to a Permission Set
• Assigning the Permission Set to selected users
• Writing an Apex Trigger that checks the user’s custom permission before allowing deactivation
If the user does not have the permission, the trigger prevents the update and shows a clear error message.
This method keeps your org secure, avoids hardcoding user Ids, and gives admins full control over who can deactivate products.
Great for Salesforce Admins, Developers, and anyone preparing for Admin or Platform Developer certifications.
===========================
Timestamps
00:00 Introduction
02:05 Create Custom Permission
02:50 Add Permission to Permission Set
05:15 Create Apex Trigger
08:55 Use Custom Permission in Trigger
11:55 Demo: Trigger in Action
12:30 Assign to a User
===========================
Trigger Code:
trigger ProductTrigger on Product2 (before update) {
for(Product2 prod: Trigger.New){
Product2 oldProd =Trigger.oldmap.get(prod.Id);
// Check if user is trying to deactivate the product
if(oldProd.IsActive == true && prod.IsActive == false){
// Validate Custom Permission
if(!FeatureManagement.checkPermission('Configure_Product_CP')){
prod.IsActive = true;
prod.addError('You do not have permission to deactivate this product');
}
}
}
}
===========================
Playlists:
SALESFORCE FLOWS PLAYLIST:
• FLOWS
OMNISTUDIO PLAYLIST:
• BUSINESS RULES ENGINE || OMNISTUDIO
SALESFORCE OUT OF THE BOX PLAYLIST:
• SALESFORCE OUT OF THE BOX
SALESFORCE APEX TRIGGERS PLAYLIST:
• APEX TRIGGERS
SALESFORCE AGENTSTUDIO PLAYLIST:
• AGENTSTUDIO
SALESFORCE DATA CLOUD PLAYLIST:
• DATA CLOUD
===========================
FOLLOW ME ON:
Instagram: / caminos_infinitos_26
LinkedIn: / linkedin.com/in/pariplab-pal-077554160
@SalesforceAIChampions
@pariplabpal
===========================
#salesforce #apex #custompermission #salesforceadmin #salesforcedeveloper #salesforcetutorial #salesforce2025 #apextrigger
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: