You need to sign in to do that
Don't have an account?
Akshay Juwa
Creating a batch class in Apex!!
Hello everyone! I'm trying to create a batch apex class for the following .
SELECT Id, PersonEmail, Brand__c, CreatedDate, Opt_Out_Preference__c FROM Account WHERE CreatedDate < 2022-09-15T16:00:53.000+0000 AND PersonEmail !=NULL AND Brand__c !=NULL AND Opt_Out_Preference__c = NULL AND Brand__c != 'Fragrance'
this is my first time using it..so I'd appreciate if you could guide me what to do next.
SELECT Id, PersonEmail, Brand__c, CreatedDate, Opt_Out_Preference__c FROM Account WHERE CreatedDate < 2022-09-15T16:00:53.000+0000 AND PersonEmail !=NULL AND Brand__c !=NULL AND Opt_Out_Preference__c = NULL AND Brand__c != 'Fragrance'
this is my first time using it..so I'd appreciate if you could guide me what to do next.
first create a class
then to make it batch class you need to
- first make class global/public and implement interface database.batchable<sObject>
- in this it is compulsory to write 3 methods
- first method is start return type database.querylocator or Iterable<sObject> and "start" name of first method name of all methods should be as defined in example code name of class can be different and variable names inside any method can be different.
- in start method you can write your query to get record
- in execute method you can perform operation what ever you need to do
- in finish method if not required you can leave this empty but defining is compulsory.
for more you can readAll Answers
What is the error you were getting?
If possible share the code.
Thanks!!
first create a class
then to make it batch class you need to
- first make class global/public and implement interface database.batchable<sObject>
- in this it is compulsory to write 3 methods
- first method is start return type database.querylocator or Iterable<sObject> and "start" name of first method name of all methods should be as defined in example code name of class can be different and variable names inside any method can be different.
- in start method you can write your query to get record
- in execute method you can perform operation what ever you need to do
- in finish method if not required you can leave this empty but defining is compulsory.
for more you can read