You need to sign in to do that
Don't have an account?
Edwards71
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; } }
Edwards is most likely correct. Try adding "?nooverride=1" to the URL so that no override happens.
All Answers
Your code works fine in my dev org - what happens when you click the button?
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.
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??
Edwards is most likely correct. Try adding "?nooverride=1" to the URL so that no override happens.