function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sriganeshsriganesh 

difference between trigger and batch apex

awaiting for reply

sfdcfoxsfdcfox

They are two, basically unrelated types of code, except for the fact that both are written in Apex Code, and either one can call the other. Triggers run each time a DML operation is called against a record. Batch Apex runs across a (possibly large) set of data and performs some type of processing on it. It is likely that batch apex will cause triggers to execute as a matter of course. It is possible, though usually unnecessary, for a trigger to call batch apex. Care must be taken by the trigger to not batch recursively or post too many batch requests at once.

Sridhar BonagiriSridhar Bonagiri
Hi,
 
Trigger
Apex can be invoked through the use of triggers. A trigger is Apexcode that executes before or after the following types of operations:
  • insert
  • update
  • delete
  • merge
  • upsert
  • undelete

Triggers can be divided into two types:

  • Before triggers can be used to update or validate record values before they are saved to the database.
  • Aftertriggers can be used to access field values that are set by the database (such as a record'sIdorlastUpdatedfield), and to affect changes in other records, such as logging into an audit table or firing asynchronous events with a queue.

Batch Apex


A developer can now employ batch Apex to build complex, long-running processes on the Force.com platform. For example, a developer could build an archiving solution that runs on a nightly basis, looking for records past a certain date and adding them to an archive. Or a developer could build a data cleansing operation that goes through all Accounts and Opportunities on a nightly basis and updates them if necessary, based on custom criteria.

 

Batch Apex is exposed as an interface that must be implemented by the developer. Batch jobs can be programmatically invoked at runtime using Apex.

You can only have five queued or active batch jobs at one time. You can evaluate your current count by viewing the Scheduled Jobs page in Salesforce or programmatically using SOAP APIto query theAsyncapexJobobject.

 

Regards,

Sridhar Bonagiri

MagulanDuraipandianMagulanDuraipandian

Trigger is a piece of apex code that will be executed after some events.

 

Batch apex is a piece of code whose behavior is background.

 

http://infallibletechie.blogspot.in/search/label/Batch%20Apex%20in%20Salesforce

 

http://infallibletechie.blogspot.in/search/label/Triggers%20in%20Salesforce

 

Check this...

 

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution and give Kudos.

LingalaLingala

most useful information