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
RitikRitik 

update probability on change of StageName

Hi,

I am trying to replace Standard Opportunity detail page with my visualforce page.
Here I am able to acheive most of the things except
    1. Probability is not getting updated while changeing StageName (in inlineEdit and not even after saving it)
  
     2. Not able to display Relatedlist hover

Note: I am not using apex:detail, instead I am using pageblock and apex:outputfield tags

below is my code snippet

<apex:form>
<apex:pageblock mode="maindetail">
  <apex:pageBlockSection title="Opportunity Related Information" id="thePageBlockSectionDetail11">
                <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton, deleteButton" event="ondblclick"
                    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit" />
               
                 <apex:outputField value="{!Opportunity.StageName}" id="stageFieldId1"/>
                <apex:outputField value="{!Opportunity.Probability}" id="probabilityFieldId"/>  
               
         </apex:pageBlockSection>
</apex:pageblock>
</apex:form>

Please reply soon. (As it is a bit urgent.)
Any help would be highly appriciated

Thanks in advance,

Ritik
Best Answer chosen by Ritik
RitikRitik
Hi ,

Vinita_SFDC thanks for your reply :).

After some hit and trial I have reached to a solution (although it does not refresh Probability when we are changing stage (at the time of inline edit) but it works well after we hit save button )

Here is the code snippet

-----------Vf-------------------
<apex:outputField value="{!Opportunity.StageName}" id="stageFieldId">
                     <apex:actionSupport event="onchange" rerender="thePageBlockSectionDetail11"/> 
</apex:outputField>

<apex:outputField value="{!opportunityStage.DefaultProbability }"/>

---------controller----------

public class Opporunitycntrlr {
    OpportunityStage opportunityStage {get; set;}
    public Opportunity Opp1 {get; set;}

    public Opporunitycntrlr(ApexPages.StandardController controller) {
        
    }

    public OpportunityStage getOpportunityStage () {
        Opp1 = [select StageName, Id from Opportunity where Id = :ApexPages.currentPage().getParameters().get('Id') limit 10];
        if (opportunityStage == null){                     
            opportunityStage = [select DefaultProbability, masterlabel from OpportunityStage where masterlabel =: Opp1.StageName order by DefaultProbability];
        }
        return OpportunityStage ;
    }
}
------------------------------------------------------

Anybody can help me in refining this code or can tell me a better solution.

Still hunting for relatedlist hover (if by any chance I can crack the solution)


Thanks,
Ritik

All Answers

Vinita_SFDCVinita_SFDC
Hello Ritik,

On saving probability after editing stagename, are you getting any error in debug log? If yes then please share.

Visualforce related list hover link is not supported as of now. Please vote following idea:

https://success.salesforce.com/ideaView?id=08730000000ZQo4AAG
RitikRitik
Hi ,

Vinita_SFDC thanks for your reply :).

After some hit and trial I have reached to a solution (although it does not refresh Probability when we are changing stage (at the time of inline edit) but it works well after we hit save button )

Here is the code snippet

-----------Vf-------------------
<apex:outputField value="{!Opportunity.StageName}" id="stageFieldId">
                     <apex:actionSupport event="onchange" rerender="thePageBlockSectionDetail11"/> 
</apex:outputField>

<apex:outputField value="{!opportunityStage.DefaultProbability }"/>

---------controller----------

public class Opporunitycntrlr {
    OpportunityStage opportunityStage {get; set;}
    public Opportunity Opp1 {get; set;}

    public Opporunitycntrlr(ApexPages.StandardController controller) {
        
    }

    public OpportunityStage getOpportunityStage () {
        Opp1 = [select StageName, Id from Opportunity where Id = :ApexPages.currentPage().getParameters().get('Id') limit 10];
        if (opportunityStage == null){                     
            opportunityStage = [select DefaultProbability, masterlabel from OpportunityStage where masterlabel =: Opp1.StageName order by DefaultProbability];
        }
        return OpportunityStage ;
    }
}
------------------------------------------------------

Anybody can help me in refining this code or can tell me a better solution.

Still hunting for relatedlist hover (if by any chance I can crack the solution)


Thanks,
Ritik
This was selected as the best answer