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
Jan JulianJan Julian 

Multiple page editors in development mode

I'm currently working on a standard controller extension for ServiceContract which is invoked via a custom button on the detail page.

 

The custom button takes the user to a visualforce page. As I'm the developer however, Salesforce, by default, will automatically show the page editor for the corresponding visualforce page and controller.

 

As I'm coding/testing out the page and its controller, a couple of annoyances happen which I can't find workarounds for.

 

1. The visualforce page has a cancel button (which uses the standard cancel action) which upon clicking DOES take the user to the ServiceContract detail page, but the URL remains in the https://Salesforce_instance/apex/myNewPageName, as opposed to https://Salesforce_instance/servicecontractId.

 

How should I implement the buttons so that the URL will correctly change?

 

Additionally, the page editor remains after I'm redirected to the detail page (which might be related to the non-changing URL). This, I think, lead to #2

 

2. Everytime I click the custom button on the ServiceContract detail page - invoking the above controller, another page editor is rendered. If i keep doing that eventually I'd get something like this:

 

 

 

 Are these bugs, or am I doing something wrong?


Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

You can write a script as below:

 

function redirect()

{

window.parent.location='your location where you want the user upon clicking on cancel button';

}

</script>

 

Then call this function on onclick of your cancel button. You have to write your code for your Cancel button as below:

 

<apex:commandButton action="{!cancel}" value="Cancel" onclick="redirect();"/>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.