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
Mahendra Singh 19Mahendra Singh 19 

Error :Error occured while loading a visualforce page Please email us if you need to get in touch.It is working fine with all records but create this error for one Id, altough that id exist in DB.

public with sharing class CaseDetails {
    
    public List<Solution> lstSolution= new List<Solution>();
    public List<CaseComment> lstComment = new List<CaseComment>();
    public List<EmailMessage> lstEmails = new List<EmailMessage>();
    public List<attachment> lstattachment = new List<attachment>();
    public boolean displayPopUp{get;set;} // set Variable for pop up show hide
    public boolean displayPopUp2{get;set;}  // set Variable for pop up show hide 
    //public List<attachment> lstattachment2 = new List<attachment>();
    //public String[] countries = new String[]{};
    public Id objId;
    User objUser = new User();
    public boolean isGoogle { get; set; }
    public boolean isShow {get;set;}
    public boolean isEdit {get;set;}
    public ID caseID;
    public Case objCaseNew{get;set;}    
    PUBLIC STRING STREMAIL{GET;SET;}
    public string priorityValue {get;set;}
    List<string> searchInfo = new List<string>();
    List<Solution> solutionList = new List<Solution>();
    Contact objContact {get;set;}
    private string priorityPriorValue ;
    public string priorityReason {get;set;}
    public boolean panalView{get;set;} 
 
    public CaseDetails(ApexPages.StandardController stdController) {
    try{
     //CaseID = ApexPages.currentPage().getParameters().get('id');
      // objCaseNew  = new Case();
        isShow =false;
        isEdit = true;
        
        
        
        objContact = new Contact();
        objUser = [select ContactId from User where id =:UserInfo.getUserId()];
        
        
        objContact = [select name,phone,email,AccountId,Account.Name from Contact where Id =: objUser.ContactId];
        
        if(objContact.Account.Name.toLowerCase().contains('google')){
           isGoogle = true;
        }
        else{
           isGoogle = false;
        }
         objId = ApexPages.currentPage().getParameters().get('id');
         this.objCaseNew = (Case)stdController.getRecord();
         if(objId!=null)
         {
           objCaseNew  =[select id,CC_Email_Ids__c,Division__c,Priority,Priority_Change_Reason__c from Case where id=:objId];
           priorityReason = objCaseNew.Priority_Change_Reason__c;
           //panalView=true;
           STREMAIL = objCaseNew.CC_Email_Ids__c ;
           
           //priorityValue = objCaseNew.priority;
           //priorityReason = objCaseNew.priority;
           priorityPriorValue = objCaseNew.priority;
           
        /*if(objCaseNew.Priority_Change_Reason__c!=null)
        {
        
        panalView=true;
        
        }else{
        
         panalView=false;
        
        }
        */
           
           
         }
         //panalView=false;
         system.debug('objCaseNew___'+objCaseNew); 
        }Catch(Exception ee){}
     }
     
     
   
    
    
    public void openpopup()
    {
    //displayPopUp = true;
        if( priorityPriorValue =='P4' && ( objCaseNew.priority == 'P3' || objCaseNew.priority == 'P2'|| objCaseNew.priority == 'P1') ){
        objCaseNew.TAC_Engineer__c = 'Unassigned';
        displayPopUp = true;
        }
        
        if(priorityPriorValue =='P3' && (objCaseNew.priority == 'P2'|| objCaseNew.priority == 'P1') ){
        objCaseNew.TAC_Engineer__c = 'Unassigned';
        displayPopUp = true;
        }
        
        if(priorityPriorValue =='P2' && objCaseNew.priority == 'P1' ){
        objCaseNew.TAC_Engineer__c = 'Unassigned';
        displayPopUp = true;
        }
        
    }
    
    public void continuepopup()
    {
        displayPopUp = false;
        displayPopUp2 = true;
    }
    
    public List<CaseComment> getComments() {
        system.debug('case details');
        lstComment = [SELECT CommentBody, CreatedDate, CreatedById FROM CaseComment WHERE ParentId =: objId ORDER BY CreatedDate desc];
        return lstComment;
    }
    
   public List<EmailMessage> getEmails() {
        system.debug('Email details');
        lstEmails = [SELECT Status, Subject,FromAddress,MessageDate,TextBody,htmlbody FROM EmailMessage WHERE ParentId =: objId ORDER BY Messagedate desc];
        return lstEmails;
    }
    public PageReference NewComment() {
        if(objCaseNew!=null)
        {
        PageReference PgRefNewComment = new PageReference('/apex/CommentsPage?CaseID='+objCaseNew.ID);
        PgRefNewComment.setRedirect(true);
        return PgRefNewComment;
        }else{
        return null;
        }
    }
                
    public List<WrapperClassSS> getAttachments() {       
       if(templist.size() == 0){
           for(attachment a: [SELECT id,name,CreatedById,Owner.name,BodyLength,CreatedDate FROM Attachment WHERE ParentId =: objId ORDER BY CreatedDate desc] ){
                WrapperClassSS templ = new WrapperClassSS();                
                if(integer.valueof(a.BodyLength) < 1024 ){
                    templ.BLength = string.valueof(a.BodyLength)+'bytes';
                }
                else if(integer.valueof(a.BodyLength) <= 1048576 ){
                    if((math.mod(integer.valueof(a.BodyLength),1024) < 512))
                        templ.BLength = string.valueof(a.BodyLength/1024)+'KB';
                    else
                        templ.BLength = string.valueof((a.BodyLength/1024)+1)+'KB';
                }
                else if(a.BodyLength > 1048576 ){
                    System.debug('===attachment length with two decimal places==='+(decimal.valueof(a.BodyLength)/1048576).setscale(2));
                    string attsize = string.valueof((decimal.valueof(a.BodyLength)/1048576).setscale(2))+'MB';
                    if(attsize.contains('.0'))
                        templ.BLength = attsize;
                    else if(attsize.contains('.00'))
                        templ.BLength = string.valueof(a.BodyLength/1048576)+'MB'; 
                    else
                        templ.BLength = string.valueof((decimal.valueof(a.BodyLength)/1048576).setscale(1))+'MB';                       
                }   
                
                templ.att = a;
                templist.add(templ);           
            }
        }
         System.debug('List of attachments'+lstAttachment);
         return templist;
    }
    list<WrapperClassSS> templist = new list<WrapperClassSS>();
    public class WrapperClassSS{        
        public string BLength{set;get;}        
        public attachment att{set;get;}        
    }
    
    public void EditMode()
    {
       system.debug('MethodCall');
       objCaseNew  =[select id,CC_Email_Ids__c,Division__c,TAC_Engineer__c,Priority,Priority_Change_Reason__c from Case where id=:objId];
       priorityPriorValue = objCaseNew.priority;
       if(objId!=null)
       {
        isShow = true;
        isEdit = false;
       }
       
    }
    
    public void SaveData()
    {     
        displayPopUp2 = false;
        displayPopUp = false;
        isShow = false;   
        isEdit = true;
        string priorityval; 
     try{
            if(objCaseNew.CC_Email_Ids__c!=null){
                List<string> lstEmail=new List<string>();
                if(objCaseNew.CC_Email_Ids__c.contains(';')){
                    lstEmail=objCaseNew.CC_Email_Ids__c.split(';');
                }else if(objCaseNew.CC_Email_Ids__c.contains(',')){
                    lstEmail=objCaseNew.CC_Email_Ids__c.split(',');
                }
                if(lstEmail.size()>0){
                    for(integer i=0;i<lstEmail.size();i++){
                        if(i==0)
                        objCaseNew.CC_Email_Id__c=lstEmail[i];
                        else if(i==1)
                        objCaseNew.CC_Email_Id2__c=lstEmail[i];
                        else if(i==2)
                        objCaseNew.CC_Email_Id3__c=lstEmail[i];
                    }
                }else{
                    objCaseNew.CC_Email_Id__c=objCaseNew.CC_Email_Ids__c;
                }
                               
            }
         priorityReason = objCaseNew.Priority_Change_Reason__c;
         system.debug('**********objCaseNew.Priority111**********'+objCaseNew.Priority);  
         update objCaseNew; 
         system.debug('**********objCaseNew.Priority222**********'+objCaseNew.Priority);
       }
       catch(Exception ex) {
            apexpages.addmessages(ex);
            return;
        }                      
    }
    
    
    
    public void cancel(){
    isShow = false; 
    objCaseNew.Priority=priorityPriorValue ;        
    }
    
    public void cancelPopUp(){ 
    displayPopUp2 = false;
    displayPopUp = false; 
    objCaseNew  =[select id,CC_Email_Ids__c,Division__c,TAC_Engineer__c,Priority,Priority_Change_Reason__c from Case where id=:objId];
        
    objCaseNew.Priority=priorityPriorValue ;     
    }
    
    
   
}


 
It is working fine with all records but create this error for one Id,  altough that id exist in DB.
SonamSonam (Salesforce Developers) 
Are you still facing this issue? Could you please share the record ID or the object whose ID you are tryint to use.Also, a screenshot f this error will help.