You need to sign in to do that
Don't have an account?
Suneel B 9
Update Probability with Stage Name
Hello Guys, i have created an Opportunity page. Problme is for a new record if i change the stageName the probability is not changing. But its changing when i Edit the record. Do i need to write an Apex class or assign field dependency, Can anyone help me out please Below is the VF Page
<apex:page standardController="Opportunity">
<apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/>
<apex:form >
<apex:pageBlock title="Opportunity Edit" helpTitle="Opportunity" helpUrl="Opportunity">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" />
<apex:commandButton action="{!QuickSave}" value="QuickSave"/>
<apex:commandButton action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Information" collapsible="false" >
<apex:outputText value="{!Opportunity.Owner}"
label="Opportunity Owner"/>
<apex:inputField value="{!Opportunity.Amount}"
label="Amount"/>
<apex:inputCheckbox value="{!Opportunity.IsPrivate}"
label="Private"/>
<apex:inputField value="{!Opportunity.CloseDate}" required="true"
label="CloseDate"/>
<apex:inputField value="{!Opportunity.Name}" required="true"
label="Opportunity Name"/>
<apex:inputText value="{!Opportunity.NextStep}"
label="NextStep"/>
<apex:inputText value="{!Opportunity.Account}"
label="Account Name"/>
<apex:inputField value="{!Opportunity.StageName}"/>
<apex:inputField value="{!Opportunity.Type}"
label="Type"/>
<apex:inputField value="{!Opportunity.Probability}"
label="Probability(%)"/>
<apex:inputField value="{!Opportunity.LeadSource}"
label="LeadSource"/>
<apex:inputText value="{!Opportunity.Campaign}"
label="Primary Campaign Source"/>
<apex:inputText value="{!Opportunity.Rating__c}"
label="Rating"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Additional Information" collapsible="false">
<apex:inputfield value="{!Opportunity.OrderNumber__c}"
label="Order Number"/>
<apex:inputfield value="{!Opportunity.MainCompetitors__c}"
label="Main Competitor(s)"/>
<apex:inputField value="{!Opportunity.CurrentGenerators__c}"
label="CurrentGenerator(s)"/>
<apex:inputfield value="{!Opportunity.DeliveryInstallationStatus__c}"
label="Delivery Installation Status"/>
<apex:inputField value="{!Opportunity.TrackingNumber__c}"
label="Tracking Number"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Description Information" collapsible="false">
<apex:inputField value="{!Opportunity.Description}"
label="Description" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</Apex:page>
<apex:page standardController="Opportunity">
<apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/>
<apex:form >
<apex:pageBlock title="Opportunity Edit" helpTitle="Opportunity" helpUrl="Opportunity">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" />
<apex:commandButton action="{!QuickSave}" value="QuickSave"/>
<apex:commandButton action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Information" collapsible="false" >
<apex:outputText value="{!Opportunity.Owner}"
label="Opportunity Owner"/>
<apex:inputField value="{!Opportunity.Amount}"
label="Amount"/>
<apex:inputCheckbox value="{!Opportunity.IsPrivate}"
label="Private"/>
<apex:inputField value="{!Opportunity.CloseDate}" required="true"
label="CloseDate"/>
<apex:inputField value="{!Opportunity.Name}" required="true"
label="Opportunity Name"/>
<apex:inputText value="{!Opportunity.NextStep}"
label="NextStep"/>
<apex:inputText value="{!Opportunity.Account}"
label="Account Name"/>
<apex:inputField value="{!Opportunity.StageName}"/>
<apex:inputField value="{!Opportunity.Type}"
label="Type"/>
<apex:inputField value="{!Opportunity.Probability}"
label="Probability(%)"/>
<apex:inputField value="{!Opportunity.LeadSource}"
label="LeadSource"/>
<apex:inputText value="{!Opportunity.Campaign}"
label="Primary Campaign Source"/>
<apex:inputText value="{!Opportunity.Rating__c}"
label="Rating"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Additional Information" collapsible="false">
<apex:inputfield value="{!Opportunity.OrderNumber__c}"
label="Order Number"/>
<apex:inputfield value="{!Opportunity.MainCompetitors__c}"
label="Main Competitor(s)"/>
<apex:inputField value="{!Opportunity.CurrentGenerators__c}"
label="CurrentGenerator(s)"/>
<apex:inputfield value="{!Opportunity.DeliveryInstallationStatus__c}"
label="Delivery Installation Status"/>
<apex:inputField value="{!Opportunity.TrackingNumber__c}"
label="Tracking Number"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Description Information" collapsible="false">
<apex:inputField value="{!Opportunity.Description}"
label="Description" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</Apex:page>
issue here is that probability will not change when you are entering data, simply because, if you are using standard controller, data is going to be processed after you evoke Save event. If you remove probability section, system is going to set default probability for that Stage.
Now, if you want to update probability in real time when ever you change stage name, there is a great article here: http://opfocus.com/blog/dynamically-updating-probability-when-selecting-stage-with-visualforce-2/
Hope this will help a little.
Dusan