<apex:page standardController="Opportunity" extensions="closeOppExtension" sidebar="false" docType="html-5.0">
<apex:messages />
<apex:form >
<apex:pageBlock title="Close Opportunity">
<p/>
<b> Please confirm that all of the information on this screen is accurate in order to close the opportunity. </b>
<apex:pageBlockSection columns="1" >
<apex:inputField value="{! Opportunity.Name }" required="true" />
<apex:inputField value="{! Opportunity.CloseDate }" required="true" />
<apex:inputField value="{! Opportunity.Type }" required="true" />
<apex:selectList id="chooseStage" value="{! selectedValue }" size="1" required="true" label="Stage" >
<apex:selectOption itemValue="" itemLabel="Please select closed stage..." />
<apex:selectOption itemValue="Deal Won" itemLabel="Deal Won" />
<apex:selectOption itemValue="Deal Lost" itemLabel="Deal Lost" />
<apex:selectOption itemValue="Disqualified" itemLabel="Disqualified" />
<apex:actionSupport event="onchange" action="{! showSection }" />
</apex:selectList>
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{! renderWon }" columns="1" >
<apex:inputField value="{! Opportunity.Amount }" required="true"/>
<apex:inputField value="{! Opportunity.ARR_Amount__c }" required="true" />
<apex:inputField value="{! Opportunity.Subscription_Start_Date__c }" required="true" />
<apex:inputField value="{! Opportunity.Subscription_End_Date__c }" required="true" />
<apex:inputText value="{! Renewal_Start }" label="Renewal License Start Date" onclick="DatePicker.pickDate(false, this, false);" onfocus="DatePicker.pickDate(false, this, false);" required="true"/>
<apex:inputText value="{! Renewal_End }" label="Renewal License End Date" onclick="DatePicker.pickDate(false, this, false);" onfocus="DatePicker.pickDate(false, this, false);" required="true"/>
<apex:inputText value="{! Renewal_Name }" label="Renewal Opportunity Name" required="true" />
<apex:inputField value="{! Opportunity.Number_of_Devices__c }" required="true" />
<apex:inputField value="{! Opportunity.Opportunity_Channel__c }" required="true" />
<apex:inputField value="{! Opportunity.Product_Interest__c }" required="true" />
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{! renderLost }" columns="1" >
<apex:inputField value="{! Opportunity.Amount }" required="true" />
<apex:inputField value="{! Opportunity.ARR_Amount__c }" />
<apex:inputField value="{! Opportunity.DQ_Loss_Reason__c }" required="true" />
<apex:inputField value="{! Opportunity.Number_of_Devices__c }" />
<apex:inputField value="{! Opportunity.Opportunity_Channel__c }" required="true" />
<apex:inputField value="{! Opportunity.Product_Interest__c }" required="true" />
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{! renderDQ }" columns="1" >
<apex:inputField value="{! Opportunity.Amount }" />
<apex:inputField value="{! Opportunity.ARR_Amount__c }" />
<apex:inputField value="{! Opportunity.Number_of_Devices__c }" />
<apex:inputField value="{! Opportunity.Opportunity_Channel__c }" />
<apex:inputField value="{! Opportunity.Product_Interest__c }" />
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{! save }" value="Save" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class closeOppExtension {
// get ID from URL
// public void ApexPages.currentPage().getParameters().get('id')
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('Deal Won','Deal Won'));
options.add(new SelectOption('Deal Lost','Deal Lost'));
options.add(new SelectOption('Disqualified','Disqualified'));
return options;
}
public String selectedValue {get; set;}
public Boolean renderWon {get; set;}
public Boolean renderLost {get; set;}
public Boolean renderDQ {get; set;}
// set all of the render pageblocks as false when the page opens
public closeOppExtension() {
renderWon = renderLost = renderDQ = false;
}
// show the appropiate pageblock based on the picklist selection
// hide the other pageblocks - important if the user chooses another picklist value
public void showSection() {
if(selectedValue == 'Deal Won') {
renderWon = true;
renderLost = false;
renderDQ = false;
}
else if(selectedValue == 'Deal Lost') {
renderWon = false;
renderLost = true;
renderDQ = false;
}
else if(selectedValue == 'Disqualified') {
renderWon = false;
renderLost = false;
renderDQ = true;
}
}
public Opportunity opp {get; set;}
public Opportunity RenewalOpp {get; set;}
// private ApexPages.StandardController stdController;
private Date today = date.today();
public Date Renewal_Start {get; set;}
public Date Renewal_End {get; set;}
public String Renewal_Name {get; set;}
// calculate standard subscription start and end dates to prepopulate input field areas
public closeOppExtension(ApexPages.StandardController stdController) {
opp = (Opportunity)stdController.getRecord();
opp.Subscription_Start_Date__c = date.newInstance(date.today().year(), date.today().month() + 1, 1);
opp.Subscription_End_Date__c = date.newInstance(date.today().year() + 1, date.today().month() + 1, 1) - 1;
Renewal_Start = date.newInstance(today.year() + 1, today.month() + 1, 1);
// date Renewal_Start = RenewalOpp.Subscription_Start_Date__c;
Renewal_End = date.newInstance(Renewal_Start.year() + 1, Renewal_Start.month() + 1, 1) - 1;
}
public ID oppID {get; set;}
}
Hi Kumar,Thank you for the response. Can you give an examle of how I should rewrite my validation requirements as I currently have them?