function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

need help for 'UNKNOWN_EXCEPTION'

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:


Source organization: 00D80000000LyP5 (null)

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



 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 = - 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){
            List<User> userList = [select id from User where IsActive = true];
            for(User u: userList){
                userIdStr = userIdStr + ',\'' + + '\'';
            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 +')';
                eventBatch.query = '';
            eventBatch.query = '';



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

    global void execute (Database.BatchableContext bc, List<sObject> scope){
        Date t = - 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';
        EventFeed[] cfList = [SELECT Id,  FROM EventFeed where ParentId = :eventIdList and CreatedDate < :t];
        for(EventFeed cf: cfList){
            update evList;
            delete fpList;
        }catch(Exception ex){

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

Raumil SetalwadRaumil Setalwad

Hello friend the mistake should be query which is used in Batch class



 Old Query :
 EventFeed[] cfList = [SELECT Id,  FROM EventFeed where ParentId = :eventIdList and CreatedDate < :t];
 Modifed Query
  EventFeed[] cfList = [SELECT Id,  FROM EventFeed where ParentId IN :eventIdList and CreatedDate < :t];

 since you are using list it will return exception try the code.


Hope this helps


Raumil Setalwad



thank for your suggestion, I do will try your code later.

but I dont think it's the main reason of the exception.