For the trigger below, trigger ProductBeforeUpdate 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('Allow_Product_Deactivate')) {
prod.IsActive = true; // Revert change
prod.addError('You do not have permission to deactivate this product.');
}
}
}
} What happens in the trigger when a user without the custom permission tries to deactivate a product?
Salesforce AI Champions
#7SalesforceQuiz#
For the trigger below,
trigger ProductBeforeUpdate 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('Allow_Product_Deactivate')) {
prod.IsActive = true; // Revert change
prod.addError('You do not have permission to deactivate this product.');
}
}
}
}
What happens in the trigger when a user without the custom permission tries to deactivate a product?
#salesforce #quiz #permissions @pariplabpal @SalesforceAIChampions
2 days ago | [YT] | 0