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
SF7SF7 

Redirect to a Standard new page From a visual force page

HI ,

I have a VF page on OpportunityContactRole and when user click AddContactRole Button from Opportunity a new page opens and users can search and add the contacts to the opportunity. However if the contact they are searching for is not found then i would like them to add the contact from there itself and then add that contact to the Opportunity.

So i would need to open a new page (window) when they click the button New Contact from the VF page and they should create a contact and save it and when done they should be back on the VF page and contunie adding the contact they cretaed to the Opportunity.

So i cretaed a new button on the VF page and it redirects to the contact but problem is it is not opening in the new window . Do i need to add Java Script for that .

Here is the code i added

              <apex:commandButton value="Save" action="{!Save}" id="quickSavebutton"/>
              <apex:commandButton value="Cancel" action="{!cancel}"/>
              <apex:CommandButton action="{!NewContact}" value="New Contact" />

public PageReference NewContact() {
       
        PageReference OpenPage = new PageReference ('/003/e');
        OpenPage.setRedirect(true);       
        return OpenPage;
     }

Thanks

SarfarajSarfaraj
Hi 

This will do,
<apex:commandButton oncomplete="window.open('/003/e');" value="New Contact" reRender="none" immediate="true" />