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
Durvesh Shah 8Durvesh Shah 8 

VisualForce: Error in RecordType Redirection in Lightning(This works perfect in classic)

User-added image
public class BuildingControllerext {
    
    public  String recordTypeId {get;set;}
    //public site__c site{get;set;}
    public string parentid{get;set;}
    public string site{get;set;}
    

    public buildingcontrollerext(ApexPages.StandardController controller)
    {
        String parentid= ApexPages.CurrentPage().getParameters().get('retURL');
        System.debug('This returnurl'+parentid);
        site =  parentid.right(15);
        System.debug('This site'+site);
    }
    
      
       public Pagereference redirectToVF()
    {
        Pagereference pg;
        String spPrefix = Building__c.SObjectType.getDescribe().getKeyPrefix(); 
       
        if(ApexPages.CurrentPage().getParameters().get('RecordType') != null )
        {      
            recordTypeId = ApexPages.CurrentPage().getParameters().get('RecordType');          
            
            if(recordTypeId == Schema.SObjectType.Building__c.getRecordTypeInfosByName().get('RCC').getRecordTypeId())
            {
               pg = new Pagereference('/apex' + '/showrcc?RecordType='+ RecordTypeId + '&site='+site);  
               pg.getParameters().put('nooverride','1');
             } 
            
                                               
            }
            else if(RecordTypeId == Schema.SObjectType.Building__c.getRecordTypeInfosByName().get('Ground/Parking').getRecordTypeId())
            {                                           
                pg = new Pagereference('/apex' + '/showground?RecordType=' + RecordTypeId + '&site='+site);  
                pg.getParameters().put('nooverride','1');
            }     
            else if(recordTypeId == Schema.SObjectType.Building__c.getRecordTypeInfosByName().get('Metal').getRecordTypeId())
            {                          
               pg = new Pagereference('/apex' + '/showmetal?RecordType=' + RecordTypeId + '&site='+site);  
                pg.getParameters().put('nooverride','1');
            }
            pg.setRedirect(true);
            return pg;
         }           
         
             return null;
         

         
    }
      
      
    
        
}