You need to sign in to do that
Don't have an account?

Homepage PageReference
Hi all,
Does anyone know how I can specify a PageReference to take the user to the homepage? I know I can use:
return new PageReference('/home');
but I don't know if this is very extensible. Does anyone know the official, Salesforce way of doing this?
Cheers
James
This may be one of solution
public class homeredirect
{public pagereference doredirect()
{pagereference pg;
pg=new pagereference('https://ap1.salesforce.com/home/home.jsp');
or u can use
pg=new pagereference('/home/home.jsp');
pg.setredirect(true);
return pg;
}
}
Hi,
Thanks for that, does anyone know if this is the official way of doing this?
The reason I ask is that Salesforce have stated with a number of other projects that things like 001 for Accounts can be changed at any point. Because I this I way wondering if there was a future (upgrade) proof way of doing this?
Cheers
James
This may be one of solution
public class homeredirect
{public pagereference doredirect()
{pagereference pg;
///pg=new pagereference('https://ap1.salesforce.com/home/home.jsp'); it will only work for ap1 instance.
or u can use
pg=new pagereference('/home/home.jsp');//work all salesforce servers.
pg.setredirect(true);
return pg;
}
}
there is a small change in the above code remove below line of code .Becuase we do't know our users is running in which salesforce instance.
pg=new pagereference('https://ap1.salesforce.com/home/home.jsp');
otehreise also you can get the server url ussing apexpagereference class host method and append it.
But this method should invoked using any button or any other option.
Thanks