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
sadasiva07sadasiva07 

while running batch apex i getting staus as "Internal salesforce.com error" in the debug log

while running batch apex i getting staus as "Internal salesforce.com error" in the debug log.

 

this is my batch class :

/******************************************************************************************
Name   : AutoArchivingArticles
 
Purpose: Archiving of Articles depend on the Archivedate which is in the "Archive_Date__c" custom field.
         Whcih is going to schedule.
         
********************************************************************************************/


global class AutoArchivingArticles implements Database.Batchable<SObject>{

    
    Public String query='select id from KnowledgeArticleVersion where publishStatus='+'\'online\'' + ' '+'And'+ ' '+'language ='+'\'en_US\'';
    
    global Database.QueryLocator start(Database.BatchableContext BC){       
             
            system.debug('___query__'+query);
            return Database.getQueryLocator('select id from KnowledgeArticleVersion where publishStatus='+'\'online\'' + ' '+'And'+ ' '+'language ='+'\'en_US\'');    
    }  
    
    global void execute(Database.BatchableContext BC, List<sObject> scope){
         system.debug('___query__'+scope);
        List<KnowledgeArticleVersion> kav= (List<KnowledgeArticleVersion>)scope;  
        
        list<ID> kavid= new list<ID>();
        
              
        // List of Type Issues Solutions
        list<Issues_Solutions__kav> KT_IS = new list<Issues_Solutions__kav>();

        // List of Type Newsletter
        list<Newsletter__kav> KT_NL = new list<Newsletter__kav >();
        
        // List of Type Policies Procedures
        list<Policies_Procedures__kav> KT_PP = new list<Policies_Procedures__kav>();
        
        // List of Type Documentation
        list<Documentation__kav> KT_Doc = new list<Documentation__kav>();
        
        // List of Type FAQs
        list<FAQs__kav> KT_FAQ = new list<FAQs__kav>();
        
        // List of Type Installation_Updates
        list<Installation_Updates__kav> KT_IU = new list<Installation_Updates__kav>();
        
        // List of Type News Alerts
        list<News_Alerts__kav> KT_NA = new list<News_Alerts__kav>();
        
        // List of Type System Requirements
        list<System_Requirements__kav> KT_SR = new list<System_Requirements__kav>();
        
        // Placeing the KnowledgeArticleVeriosn ID's into a list
        
        for(KnowledgeArticleVersion K:kav){
            kavid.add(K.id);
        }
        
        Date Current_Date=system.today();   
        KT_IS=[select id,Archive_Date__c,Title,ArticleNumber from Issues_Solutions__kav where id IN : kavid and publishStatus='online' And language ='en_US' And Archive_Date__c=:Current_Date];
        KT_NL=[select id,Archive_Date__c,Title,ArticleNumber from Newsletter__kav where id IN : kavid and publishStatus='online' And language ='en_US' And Archive_Date__c=:Current_Date ];
        KT_PP=[select id,Archive_Date__c,Title,ArticleNumber from Policies_Procedures__kav where id IN : kavid and publishStatus='online' And language ='en_US' And Archive_Date__c=:Current_Date];
        KT_Doc=[select id,Archive_Date__c,Title,ArticleNumber from Documentation__kav where id IN : kavid and publishStatus='online' And language ='en_US' And Archive_Date__c=:Current_Date ];
        KT_FAQ=[select id,Archive_Date__c,Title,ArticleNumber from FAQs__kav where id IN : kavid and publishStatus='online' And language ='en_US' And Archive_Date__c=:Current_Date ];
        KT_IU=[select id,Archive_Date__c,Title,ArticleNumber from Installation_Updates__kav where id IN : kavid and publishStatus='online' And language ='en_US' And Archive_Date__c=:Current_Date ];
        KT_NA=[select id,Archive_Date__c,Title,ArticleNumber from News_Alerts__kav  where id IN : kavid and publishStatus='online' And language ='en_US' And Archive_Date__c=:Current_Date ];
        KT_SR=[select id,Archive_Date__c,Title,ArticleNumber from System_Requirements__kav where id IN : kavid and publishStatus='online' And language ='en_US' And Archive_Date__c=:Current_Date ];
        
        
        //Placing the Ariticle numbers into a list
        
        list<String> lArticleNumber= new list<String>();
                
        for(Issues_Solutions__kav k1:KT_IS){
            system.debug('___date chking__'+k1.Archive_Date__c);
            if(k1.Archive_Date__c==system.today()){
                lArticleNumber.add(k1.ArticleNumber);
            }
        }
        
        for(Newsletter__kav k1:KT_NL){
            system.debug('___date chking__'+k1.Archive_Date__c);
            if(k1.Archive_Date__c==system.today()){
                lArticleNumber.add(k1.ArticleNumber);
            }
        }
        
        for(Policies_Procedures__kav k1:KT_PP){
            system.debug('___date chking__'+k1.Archive_Date__c);
            if(k1.Archive_Date__c==system.today()){
                lArticleNumber.add(k1.ArticleNumber);
            }
        }
        
        for(Documentation__kav k1:KT_Doc){
            system.debug('___date chking__'+k1.Archive_Date__c);
            if(k1.Archive_Date__c==system.today()){
                lArticleNumber.add(k1.ArticleNumber);
            }
        }
        
        for(FAQs__kav k1:KT_FAQ){
            system.debug('___date chking__'+k1.Archive_Date__c);
            if(k1.Archive_Date__c==system.today()){
                lArticleNumber.add(k1.ArticleNumber);
            }
        }
        
        for(Installation_Updates__kav k1:KT_IU){
            system.debug('___date chking__'+k1.Archive_Date__c);
            if(k1.Archive_Date__c==system.today()){
                lArticleNumber.add(k1.ArticleNumber);
            }
        }
        
        for(News_Alerts__kav k1:KT_NA){
            system.debug('___date chking__'+k1.Archive_Date__c);
            if(k1.Archive_Date__c==system.today()){
                lArticleNumber.add(k1.ArticleNumber);
            }
        }
        
        for(System_Requirements__kav k1:KT_SR){
            system.debug('___date chking__'+k1.Archive_Date__c);
            if(k1.Archive_Date__c==system.today()){
                lArticleNumber.add(k1.ArticleNumber);
            }
        }
        
       
        list<KnowledgeArticle>  listknow= new list<KnowledgeArticle> ();
        listknow=[select id,ArticleNumber from KnowledgeArticle where ArticleNumber IN : lArticleNumber ];
        
        
        for(KnowledgeArticle K:listknow){
            Date ScheduleDate= system.today();
            KbManagement.PublishingService.archiveOnlineArticle(K.id,ScheduleDate);
         }
                  
       }
       
       
       global void finish(Database.BatchableContext BC){
       }     
            
}

AmitSahuAmitSahu

Retry after sometime and if not resolved .. Then please log a case with Salesforce support. This seems to be an issue at server end.