+ Start a Discussion
vepakvepak 

Return to salesforce instance from custom controller

Hi Guys,

 

I've a custom button, when it is clicked it creates new record in another custom object and the user is redirected to newly created record.

 

I use pagereference class to perform this logic. But when I redirect the user to the newly created record, user stays in the visualforce page instead of salesforce instance

 

i.e...  User stays in this URL https:/INSTANCE.visual.force.com/apex/ConvertintoCustomer?scontrolCaching=1&id=a0LE00000001ChS

 

instead of

 

https://INSTANCE.salesforce.com/a0LE00000001ChS

 

How I can redirect user to the above URL instead of visual.force.com

 

 

Thanks,

Vamsi.

Best Answer chosen by Admin (Salesforce Developers) 
Chamil MadusankaChamil Madusanka

Hi,

You are in developer org and your user has enabled the development mode. That's why you were seeing the visualforce editor. If you don't see the editor you can disable from your user record.

 

YourName --> Setup --> ManageUser --> User --> Edit Your User record (You have to uncheck the  "Development Mode" in user record)

 

OR

 

You can append following URL portion to your URL

 

&core.apexpages.devmode.url=1

 It will hide the visualforce editor even your user has the development mode feature.

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

All Answers

Rahul SharmaRahul Sharma

Hi Vamsi,

How are you using the page reference for redirection?

vepakvepak

Hi Rahul,

 

Thanks for your quick response.

 

Here is the code.

 

Return new PageReference(URL.getSalesforceBaseUrl().toExternalForm()+'/'+newcon);

  newcon variable stores id of the newly created record.

 

Thanks,

Vamsi.

Rahul SharmaRahul Sharma

try this:

you have loaded pagereference with full url of salesforce, so just you need to use partial url.

remaining would be automatically genereted(prepended by server url)

Return new PageReference('/'+newcon);

 Hope it helps.

vepakvepak

Hi Rahul,

 

I've already tried your solution, but when it redirects, it stays in the visualforce page URL with 

"visualforce pages development tools" footer (a ribbon on the bottom of the page with visualforce page and its custom controller) at the bottom of the page, and never goes to he main instance.

 

Again, Thank you for our tim.

 

Thanks,

Vamsi.

Rahul SharmaRahul Sharma

I didn't get the problem you are facing?

could you explain a bit.

vepakvepak

I'm working in the developer edition, As I said if I click on the button, it redirects to the newly created record in the same window with the ribbon I pointed in the below image on the bottom of the page. and the URL will be https://na9.visual.force.com/apex/ConvertintoCustomer?id=a0LE00000001ChS&scontrolCaching=1 instead of https://na9.salesforce.com/a0LE00000001ChS.

Rahul SharmaRahul Sharma

Hello,

Are you redirecting the whole page or only the iFrame?

also try turning off the development .

vepakvepak

Hi Rahul,

 

I'm not sure about redirecting the whole page or the iFrame. All i'm using is the redirect pagereference class.

 

Moreover I'm not sure turning off development.

 

I'll be glad if you could further explain me on this.

 

Thanks,

Vamsi.

kiranmutturukiranmutturu

just go to user detail page and you can find a check box there named as Development Mode ... uncheck the same

Chamil MadusankaChamil Madusanka

Hi,

You are in developer org and your user has enabled the development mode. That's why you were seeing the visualforce editor. If you don't see the editor you can disable from your user record.

 

YourName --> Setup --> ManageUser --> User --> Edit Your User record (You have to uncheck the  "Development Mode" in user record)

 

OR

 

You can append following URL portion to your URL

 

&core.apexpages.devmode.url=1

 It will hide the visualforce editor even your user has the development mode feature.

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

This was selected as the best answer
vepakvepak

Hi Chamil,

 

Thank you for your advice. I could able to test one of your solutions, if I uncheck the Development Mode in the user profile, it solved my requirement. 

 

But, the second solution didn't worked for me, I think I'm not sure where I need to add it in the URL.

 

Here is how my return URL look like

 

return new PageReference(URL.getSalesforceBaseUrl().toExternalForm()+'/'+newcon);

Could you please suggest me where I need to add the code that you suggested in the above.

 

Thanks,

Vamsi.

 

Chamil MadusankaChamil Madusanka

Hi,

 

Append the url segment as follows;  

 

return new PageReference(URL.getSalesforceBaseUrl().toExternalForm()+'/'+newcon+'?core.apexpages.devmode.url=1');

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

 

Chamil's Blog

vepakvepak

HI Chamil,

 

For some reason, when the developer mode is checked, this solution is not working.

 

Thanks,

Vamsi.