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
Edwards71Edwards71 

Visualforce redirection to a Standard salesforce page

Hi,

 

I have a simple Visualforce page that has two <apex:commandbutton> actions.

 

one button redirects the user to another Visualforce page which works fine.

the other button I want to redirect to the standard object contract page to create a new contract record. I can't seem to get the code right to make this bit work. any ideas?

 

Thanks in advance

<apex:page standardController="Contract" extensions="ExtNewContract">
<apex:form >
<apex:pageBlock title="New Contract Selection" mode="edit">
             <apex:pageBlockButtons >
                <apex:commandButton action="{!Cancel}" value="Cancel"/>
            </apex:pageBlockButtons>


  <apex:pageBlockSection title="Contract Details" columns="2">
        <apex:CommandButton action="{!NewImplementation}" value="New Implementation" />
        <apex:CommandButton action="{!Newhistoric}" value="New Historic contract" />
        
</apex:pageblocksection>
</apex:pageblock>

</apex:form>
</apex:page>

 

public class ExtNewContract {

public ExtNewContract(ApexPages.StandardController controller) {
 }

public PageReference NewHistoric() {
        
        PageReference secondPage = Page.Historic_contract;
        secondPage.setRedirect(true);
        
        return secondPage; 
     }

public PageReference NewImplementation() {
        
        PageReference secondPage = new PageReference ('/800/e');
        secondPage.setRedirect(true);        
        return secondPage; 
     }
     
  }

 

 

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Edwards is most likely correct. Try adding "?nooverride=1" to the URL so that no override happens.

All Answers

bob_buzzardbob_buzzard

Your code works fine in my dev org - what happens when you click the button?

Edwards71Edwards71

Hi - when I click the 'New Implementation' button it just returns to the visualforce page.  when I click the 'Historic contract' button this correctly redirects to a Visualforce page.

Edwards71Edwards71

on reflection I'm wondering whether this a circular reference issue.

 

The visualforce page giving the option for either a New implementation or a Historic one is a replacement for 'New" button on the Contract object.

 

Is it possible that the New implementation button is therefore just opening up itself??

 

 

sfdcfoxsfdcfox

Edwards is most likely correct. Try adding "?nooverride=1" to the URL so that no override happens.

This was selected as the best answer