• Link_ZX
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

I am doing a scheduled batch function. When I runing the batch class, it will occur a 'UNKNOWN_EXCEPTION' this is the information of the exception:

 

Apex script unhandled exception by user/organization:

005M0000000Dk0p/00DM00000008c2d

Source organization: 00D80000000LyP5 (null)

Failed to process batch for class 'HsAppExtEventBatchClass' for job id

'707M00000004nRD'

 

 caused by: System.DmlException: Update failed. First exception on row 96 with id 00UM00000016W9HMAU; first error: UNKNOWN_EXCEPTION, An unknown exception has occurred.: []

 

 Class.HsAppExtEventBatchClass.execute: line 40, column 6 External entry point

 

Is here any one can  provide me with any solutions or suggestions?

Thank you!

 

-------------------------schedule class----------------------------------

        Date t = system.today() - 365;

        List<Id> tempList = new List<Id>();
        String accountIdStr = '';
        String userIdStr = '';
        HsAppExtEventBatchClass eventBatch = new HsAppExtEventBatchClass();
        
        List<Event> el = [Select AccountId From Event where EndDateTime < :t and AccountId <> null and IsDeleted = false];
        if(el != null && el.size() != 0){
            for(Event ev: el){
                tempList.add(ev.AccountId);
            }    
            
            List<User> userList = [select id from User where IsActive = true];
            for(User u: userList){
                userIdStr = userIdStr + ',\'' + u.id + '\'';
            }
            userIdStr = userIdStr.substring(1,userIdStr.length());
            
            List<Contact> conList = [Select AccountId From Contact where AccountId = :tempList and Litigation_Hold__c != true and AccountId <> null and IsDeleted = false];
            if(conList != null && conList.size() != 0){    
                for(Contact con: conList){
                    accountIdStr = accountIdStr + ',\'' + con.AccountId + '\'';
                }
                accountIdStr = accountIdStr.substring(1,accountIdStr.length());
                eventBatch.query = 'select id,PreCall__c, RecordTypeId, PostCall__c, Status__c, Description, EndDateTime,StartDateTime,DurationInMinutes From Event where AccountId in ('+ accountIdStr +') and OwnerId in ('+ userIdStr +')';
            }else{
                eventBatch.query = '';
            }                    
        }else{
            eventBatch.query = '';
        }
                       
        Database.executeBatch(eventBatch);

--------------------------------------------end----------------------------------

 

--------------------------------------batch class---------------------------

    global void execute (Database.BatchableContext bc, List<sObject> scope){
        Date t = system.today() - 365;
        RecordType rt  = [select id,name from RecordType where name='Locked Activity Type'];
        List<Event> evList = new List<Event>();
        List<FeedPost> fpList = new List<FeedPost>();
        List<ID> eventIdList = new List<ID>();
       
        for(sObject s : scope){
            Event ev = (Event)s;
            ev.PreCall__c = null;
            ev.PostCall__c = null;
            ev.Description = null;
            ev.RecordTypeId = rt.Id;      
            ev.Status__c = 'Did not occur';
            if(ev.DurationInMinutes>0){
                evList.add(ev);
                eventIdList.add(ev.id);
            }            
        }
       
        EventFeed[] cfList = [SELECT Id, FeedPost.id  FROM EventFeed where ParentId = :eventIdList and CreatedDate < :t];
        for(EventFeed cf: cfList){
                fpList.add(cf.FeedPost);
        }    
        
        try{
            update evList;
            delete fpList;
        }catch(Exception ex){
            system.debug(ex);
        }
    }

-------------------------------------batch end--------------------------------------------------

I am doing a scheduled batch function. When I runing the batch class, it will occur a 'UNKNOWN_EXCEPTION' this is the information of the exception:

 

Apex script unhandled exception by user/organization:

005M0000000Dk0p/00DM00000008c2d

Source organization: 00D80000000LyP5 (null)

Failed to process batch for class 'HsAppExtEventBatchClass' for job id

'707M00000004nRD'

 

 caused by: System.DmlException: Update failed. First exception on row 96 with id 00UM00000016W9HMAU; first error: UNKNOWN_EXCEPTION, An unknown exception has occurred.: []

 

 Class.HsAppExtEventBatchClass.execute: line 40, column 6 External entry point

 

Is here any one can  provide me with any solutions or suggestions?

Thank you!

I am doing a scheduled batch function. When I runing the batch class, it will occur a 'UNKNOWN_EXCEPTION' this is the information of the exception:

 

Apex script unhandled exception by user/organization:

005M0000000Dk0p/00DM00000008c2d

Source organization: 00D80000000LyP5 (null)

Failed to process batch for class 'HsAppExtEventBatchClass' for job id

'707M00000004nRD'

 

 caused by: System.DmlException: Update failed. First exception on row 96 with id 00UM00000016W9HMAU; first error: UNKNOWN_EXCEPTION, An unknown exception has occurred.: []

 

 Class.HsAppExtEventBatchClass.execute: line 40, column 6 External entry point

 

Is here any one can  provide me with any solutions or suggestions?

Thank you!

 

-------------------------schedule class----------------------------------

        Date t = system.today() - 365;

        List<Id> tempList = new List<Id>();
        String accountIdStr = '';
        String userIdStr = '';
        HsAppExtEventBatchClass eventBatch = new HsAppExtEventBatchClass();
        
        List<Event> el = [Select AccountId From Event where EndDateTime < :t and AccountId <> null and IsDeleted = false];
        if(el != null && el.size() != 0){
            for(Event ev: el){
                tempList.add(ev.AccountId);
            }    
            
            List<User> userList = [select id from User where IsActive = true];
            for(User u: userList){
                userIdStr = userIdStr + ',\'' + u.id + '\'';
            }
            userIdStr = userIdStr.substring(1,userIdStr.length());
            
            List<Contact> conList = [Select AccountId From Contact where AccountId = :tempList and Litigation_Hold__c != true and AccountId <> null and IsDeleted = false];
            if(conList != null && conList.size() != 0){    
                for(Contact con: conList){
                    accountIdStr = accountIdStr + ',\'' + con.AccountId + '\'';
                }
                accountIdStr = accountIdStr.substring(1,accountIdStr.length());
                eventBatch.query = 'select id,PreCall__c, RecordTypeId, PostCall__c, Status__c, Description, EndDateTime,StartDateTime,DurationInMinutes From Event where AccountId in ('+ accountIdStr +') and OwnerId in ('+ userIdStr +')';
            }else{
                eventBatch.query = '';
            }                    
        }else{
            eventBatch.query = '';
        }
                       
        Database.executeBatch(eventBatch);

--------------------------------------------end----------------------------------

 

--------------------------------------batch class---------------------------

    global void execute (Database.BatchableContext bc, List<sObject> scope){
        Date t = system.today() - 365;
        RecordType rt  = [select id,name from RecordType where name='Locked Activity Type'];
        List<Event> evList = new List<Event>();
        List<FeedPost> fpList = new List<FeedPost>();
        List<ID> eventIdList = new List<ID>();
       
        for(sObject s : scope){
            Event ev = (Event)s;
            ev.PreCall__c = null;
            ev.PostCall__c = null;
            ev.Description = null;
            ev.RecordTypeId = rt.Id;      
            ev.Status__c = 'Did not occur';
            if(ev.DurationInMinutes>0){
                evList.add(ev);
                eventIdList.add(ev.id);
            }            
        }
       
        EventFeed[] cfList = [SELECT Id, FeedPost.id  FROM EventFeed where ParentId = :eventIdList and CreatedDate < :t];
        for(EventFeed cf: cfList){
                fpList.add(cf.FeedPost);
        }    
        
        try{
            update evList;
            delete fpList;
        }catch(Exception ex){
            system.debug(ex);
        }
    }

-------------------------------------batch end--------------------------------------------------

I am doing a scheduled batch function. When I runing the batch class, it will occur a 'UNKNOWN_EXCEPTION' this is the information of the exception:

 

Apex script unhandled exception by user/organization:

005M0000000Dk0p/00DM00000008c2d

Source organization: 00D80000000LyP5 (null)

Failed to process batch for class 'HsAppExtEventBatchClass' for job id

'707M00000004nRD'

 

 caused by: System.DmlException: Update failed. First exception on row 96 with id 00UM00000016W9HMAU; first error: UNKNOWN_EXCEPTION, An unknown exception has occurred.: []

 

 Class.HsAppExtEventBatchClass.execute: line 40, column 6 External entry point

 

Is here any one can  provide me with any solutions or suggestions?

Thank you!