You need to sign in to do that
Don't have an account?
rmranjith8881.3927046400771116E12
By using Batch Apex update all the records?
Hi Everyone,
I have date field,if i change this in one record,it will affects all the records by using batch apex,
will it possible?
If possible how?
Thanks in advance..............
I have date field,if i change this in one record,it will affects all the records by using batch apex,
will it possible?
If possible how?
Thanks in advance..............
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm
Thanks for reply,
I didn't get any solution for this so far,
This is my Scenario,
Scenario:
I Have Rollup since date field on household object,
when i change the date in one household it affects(updates) all households.
For that I created one Batch apex class and iam running that batch apex with one Trigger,both executes perfectly,
when we run the job it processed.but it didn't return result.
Iam posting my batch apex class and trigger,
can you verify and guide me right way,
Batch apex class:
global class houseHoldUpdate implements Database.Batchable<sObject> {
Map<Id, npo02__Household__c> hHMap = new Map<Id, npo02__Household__c>();
global houseHoldUpdate(Map<Id, npo02__Household__c> houseHolds) {
hHMap = houseHolds;
}
global Database.QueryLocator start(Database.BatchableContext BC) {
return DataBase.getQueryLocator
([select Id, name, Rollup_Since__c, Rollup_ends__c
From npo02__Household__c
where Id IN : hHMap.keyset()]);
}
global void execute(Database.BatchableContext BC, list<npo02__Household__c> scopehh) {
for (Integer i=0;i<scopehh.size();i++){
scopehh.get(i).Rollup_Since__c=hHMap.get(scopehh.get(i).Id).Rollup_Since__c;
System.debug('size is'+scopehh.size());
}
update scopehh;
}
global void finish(Database.BatchableContext BC) {}
}
Trigger:
trigger houseHoldsUpdate on npo02__Household__c (after update) {
Map<id, npo02__Household__c> houseHoldMap = new Map<id, npo02__Household__c>();
for (Integer i=0;i<Trigger.new.size();i++) {
if (Trigger.old[i].Rollup_Since__c!=Trigger.new[i].Rollup_Since__c) {
houseHoldMap.put(Trigger.old[i].Id, Trigger.new[i]);
system.debug('houseHoldMap.size: '+houseHoldMap.size());
}
}
// You can execute batch apex using trigger using below codes
if (houseHoldMap.size() > 0) {
Database.executeBatch(new houseHoldUpdate(houseHoldMap));
}
}