You need to sign in to do that
Don't have an account?
Jan Dippenaar
Apex Code assistance
Hi all,
We need to improve the code on the below so that our batch job does not time out, this is as per SF support advise.
What would be the best way to go about this? see code below
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public opportunityUtils(list<Opportunity> newOppys, map<Id,Opportunity> oldOppysMap, string operation){
// Do some validation on the Opportunity Amount & Record Type
if(operation == 'validation'){
for(Opportunity oppy :newOppys){
// TO-DO: Need to add in the Batch__c Lookup to the below logic - also need to consider other fields
if(oppy.Batch_Closed__c == true && (oppy.Amount != oldOppysMap.get(oppy.Id).Amount || oppy.RecordTypeId != oldOppysMap.get(oppy.Id).RecordTypeId)){
oppy.addError('ERROR');
}
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks all
J
We need to improve the code on the below so that our batch job does not time out, this is as per SF support advise.
What would be the best way to go about this? see code below
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public opportunityUtils(list<Opportunity> newOppys, map<Id,Opportunity> oldOppysMap, string operation){
// Do some validation on the Opportunity Amount & Record Type
if(operation == 'validation'){
for(Opportunity oppy :newOppys){
// TO-DO: Need to add in the Batch__c Lookup to the below logic - also need to consider other fields
if(oppy.Batch_Closed__c == true && (oppy.Amount != oldOppysMap.get(oppy.Id).Amount || oppy.RecordTypeId != oldOppysMap.get(oppy.Id).RecordTypeId)){
oppy.addError('ERROR');
}
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks all
J
So, my ignorance aside, there is nothing in that code sample that is causing me any concern. I'm wondering if either SF support has sent you off on a wild goose chase or is it that it's the rest of the code pattern in the batch process that is the cause. I.e. has SF support said the code is timing out and when it times out it's in this method? If that's the case then it may just be the victim rather than the culprit.