Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Prevent deletion of Account records with more than 100 related Contacts.
trigger PreventAccountDelete on Account (before delete) {
for(Account acc : Trigger.old) {
Integer contactCount = [SELECT COUNT() FROM Contact WHERE AccountId = :acc.Id];
if(contactCount > 100) {
acc.addError('Cannot delete account with more than 100 contacts');
}
}
}Salesforce Scripting refers to the use of programming and declarative scripting tools within Salesforce to automate processes, customize behavior, and extend the platform using Apex, Visualforce, Lightning Web Components, and Flow.
Origin & Creator
Developed by Salesforce.com, introduced in the mid-2000s to enable custom business logic on the cloud-based CRM platform.
Industrial Note
Extensively used in CRM automation, enterprise SaaS customization, and custom application development on Salesforce clouds.