You need to sign in to do that
Don't have an account?
Marketing Marketing 27
Embedded Visual Force Page not Opening Pages in New Tab
I have a visual force page with two buttons in my Opportunity Page Layout. The buttons are linked to a controller that runs a multipage wizard.
When clicking the button, it should open a new tab with Page 1 of the wizard, but instead it opens in on the opportunity page itself which I don't want.
here is the page:
Here is the top part of the controller.
What am I doing wrong?
When clicking the button, it should open a new tab with Page 1 of the wizard, but instead it opens in on the opportunity page itself which I don't want.
here is the page:
<apex:page standardController="Opportunity" Extensions="create504Controller" tabStyle="Opportunity" sidebar="false" lightningStylesheets="true"> <!-- make sure to add syling attributes to the text on this page --> <h2><Strong>To Create a 504 2nd Trust Deed, Click Here</Strong></h2><br/> <apex:form > <apex:commandButton action="{!step1}" value="Create 504 2nd TD"/> <apex:commandButton action="{!save}" value="Edit 504 2nd TD Details"/> </apex:form> </apex:page>
Here is the top part of the controller.
public class create504Controller { Opportunity TD1st; Opportunity TD2nd; String OppId; public create504Controller(ApexPages.StandardController controller) { OppId = controller.getId(); this.TD1st = Database.query(getQueryStatement(1)); } public Opportunity getTD1st(){ if(TD1st == NULL) TD1st = new Opportunity(); this.TD2nd = Database.query(getQueryStatement(2)); return this.TD1st; } public Opportunity getTD2nd(){ if(TD2nd == NULL) TD2nd = new Opportunity(); return this.TD2nd; } public PageReference step1(){ ApexPages.StandardController sc = new ApexPages.StandardController(this.TD1st); return Page.create504pg1; } public PageReference step2(){ return Page.create504pg2; } public PageReference Finish(){ insert TD2nd; update TD1st; PageReference originalOpp = new PageReference('lightning/r/Opportunity/' + this.TD1st.Id + '/view'); Return originalOpp; } public PageReference Cancel(){ PageReference originalOpp = new PageReference('lightning/r/Opportunity/' + this.TD1st.Id + '/view'); Return originalOpp; } public PageReference Edit5042nd(){ PageReference OppTD2nd = new PageReference('lightning/r/Opportunity/' + this.TD2nd.Id + '/view'); Return OppTD2nd; } public static String getQueryStatement(Integer option){ String selectStatement = 'SELECT name, AccountId, Amount' +'FROM Opportunity '; String whereStatement1st = ' WHERE Id =: OppId LIMIT 1 '; String whereStatement2nd = ' WHERE X504_Related_Opportunity__c =: OppId LIMIT 1 '; String queryStatement; If(option == 1){ queryStatement = (selectStatement + whereStatement1st); } else if (option == 2){ queryStatement = (selectStatement + whereStatement2nd); } System.debug('statement '+queryStatement); return queryStatement; } }
What am I doing wrong?
You can change apex:commandButton to apex:commandLink and use target attribute(_blank)
Please mark this as best answer if it helps you.
Regards,
Rajan