Batch Apex to Update Opportunities - Salesforce-scripting Typing CST Test
Loading…
Batch Apex to Update Opportunities — Salesforce-scripting Code
Batch Apex class to update Opportunity Stage to 'Closed Won'.
global class OpportunityBatch implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC) {
return Database.getQueryLocator('SELECT Id FROM Opportunity WHERE StageName = 'Prospecting'');
}
global void execute(Database.BatchableContext BC, List<Opportunity> scope) {
for(Opportunity opp : scope) {
opp.StageName = 'Closed Won';
}
update scope;
}
global void finish(Database.BatchableContext BC) {}
}Salesforce-scripting Language Guide
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.
Primary Use Cases
- ▸Custom triggers and business logic via Apex
- ▸Automating repetitive tasks using Flows and Process Builder
- ▸Extending Salesforce UI using LWC or Visualforce
- ▸Data validation and integration with external systems
- ▸Building custom objects, workflows, and reports
Notable Features
- ▸Cloud-native scripting on Salesforce platform
- ▸Strong integration with standard objects and APIs
- ▸Event-driven triggers for data changes
- ▸Low-code automation via Flows and Process Builder
- ▸Secure, multi-tenant execution with governor limits
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.