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
vikas Bhardwaj 21vikas Bhardwaj 21 

navigate to standard lightning record create page from apex class

I have a requirement where the user who are in salesforce classic would navigate to custom visualforce page and other users who are in lightning experience would navigate to standard Opportunity record create page from Opportunity related list on Account. Issue is that Account Name is not getting populated on the popup of standard New Opportunity record create page.

Below is the code snippet of the Apex class.
public with sharing class CPQ_OppEditHandlerVFC{
    
    Id oppId;
    public static string getRecordTypeId;
    Opportunity oppAccId {get;set;}
    id AccountId;
    string RecTypId;// GLM-58
    String USOppRecType = Label.US_Opportunity; // GLM -58
    public CPQ_OppEditHandlerVFC(ApexPages.StandardController controller) {
        oppId = controller.getId();
        oppAccId = (Opportunity)controller.getRecord();
        AccountId =ApexPages.currentPage().getParameters().get('accid');
        RecTypId = ApexPages.currentPage().getParameters().get('RecordType');
        userTheme =  UserInfo.getUiThemeDisplayed(); //  GLM-58
        
    }
    
 public pageReference redirect() {    
 if(userTheme == 'Theme4d'){
                        ReturnPage = new PageReference('/006/e?ent=Opportunity&RecordType='+RecordTypeId+'&accid='+AccountId+'&nooverride=1'); 
                       
                    }else{ // End - GLM-58    
                        ReturnPage = new PageReference('/apex/Custom_OpportunityEditPage?retURL=%2F006%2Fo&RecordType='+RecordTypeId+'&accid='+AccountId+'&ent=Opportunity&save_new=1&sfdc.override=1');
                    } // GLM-58

}
}