• Jan Dippenaar
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
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