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
abu saleh khan 8abu saleh khan 8 

When ever i create new opportunity from opportunity object it should through pop.opportunity new page should open to create records from contact.How to achive it.

Vf Page:

<apex:page StandardController="Opportunity" extensions="PopupOnOpportunity">
  <apex:form>
     
    <apex:outputPanel id="tstpopup">
    <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
    <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
                Can't create opportuinity from here. Please click OK to create opportunity.<br/><br/><br/>
      <apex:commandButton value="OK" action="{!clickok}" />
   </apex:outputPanel>
    </apex:outputPanel>
  </apex:form>
   <style type="text/css">
        .custPopup{
            background-color: white;
            border-width: 2px;
            border-style: solid;
            z-index: 9999;
            left: 50%;
            padding:10px;
            position: absolute;
            /* These are the 3 css properties you will need to change so the popup 
            displays in the center of the screen. First set the width. Then set 
            margin-left to negative half of what the width is. You can add 
            the height property for a fixed size pop up if you want.*/
            width: 500px;
            margin-left: -250px;
            top:100px;
        }
        .popupBackground{
            background-color:black;
            opacity: 0.20;
            filter: alpha(opacity = 20);
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 9998;
        }

    </style>
</apex:page>


Apex:
public class PopupOnOpportunity {
    public boolean displayPopup {get; set;}
    public static Integer count = 0;
    public PopupOnOpportunity(ApexPages.StandardController controller){
        //Opportunity op = new Opportunity();
        if(count == 0){ 
            displayPopup = true;
        }else{
            displayPopup = false;
        }
    }
    public Pagereference clickok(){
        count++;
        Pagereference pr = new Pagereference('/003/o?nooverride=1');
        
        pr.setRedirect(true);
        System.debug('Count is: ' +count);
        return pr;
    }
}