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
prathap pendemprathap pendem 

pageReference Errors

public class pageref{
    Account account;
    public Account getAccount(){
        if(account==null){
            account =new Account();}
        return account;
        
    }
    public pageReference save(){
        insert account;
       PageReference acctPage = new ApexPages.StandardController(account).view();
        acctPage.setRedirect(true);
        return acctPage;
    }

}

 

 

 

 

Error: Illigal assignment from system.pagereference to pagreference

 

 

can any body plz help me?

 

Vinit_KumarVinit_Kumar

Prathap,

 

Try the below code,it worked for me :-

 

public class mySecondController {
Account account;

public Account getAccount() {
if(account == null) account = new Account();
return account;
}

public PageReference save() {
// Add the account to the database.
insert account;
// Send the user to the detail page for the new account.
PageReference acctPage = new ApexPages.StandardController(account).view();
acctPage.setRedirect(true);
return acctPage;
}
}

prathap pendemprathap pendem

Hi vinit

that code also not working for me ,same error i am getting. do you know why it is happening.

Vinit_KumarVinit_Kumar

Not sure as why it is not working for me because it is working for me.Can you check debug logs if possible.

prathap pendemprathap pendem

Hi vinit, 

 

I tested the same code in my free edition, it is working, but it wont for developer edition. do you have any idea