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
SteveOCSteveOC 

Forecast Category & Probability Fields not tied to Stage in VF Oppty page

I just want to create a simple VF page that includes logic to message a salesperson when the Opp Stage = Won. The messaging works fine, but when I rerender the pageblock based on a stage update, the forecast category and probability do not update along with the stage. This doesn't make sense to me, I'm using the standard opp controller, and the stage is tied to the forecast category and probabily.

 

Does anyone know why the forecastcategoryname field and probability field would not update on a visualforce page when the stageName field is updated, and rerenders the pageblock?

 

<apex:page standardController="Opportunity" sidebar="false" extensions="OppWonExtension"> <apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/> The opportunity amount is the sum of the related products. To edit the total amount, you must first delete all of the products from the opportunity. <apex:form > <apex:pageBlock title="Edit Opportunity" id="PageBlock1" mode="edit"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:actionRegion > <apex:pagemessage severity="confirm" strength="3" summary="{!DealsheetMessage}" rendered="{!DealsheetMessage != ''}"> </apex:pagemessage> <apex:pageBlockSection title="Opportunity Information" columns="2" id="OppInfo"> <apex:inputField value="{!opportunity.name}"/> <apex:pageBlockSectionItem > <apex:outputLabel value="Stage"/> <apex:outputPanel > <apex:inputField value="{!opportunity.stageName}"> <apex:actionSupport event="onchange" rerender="PageBlock1" status="status"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status"/> </apex:outputPanel> </apex:pageBlockSectionItem> <apex:inputField value="{!opportunity.account.name}"/> <apex:inputField value="{!Was_This_Revised__c}"/> <apex:inputField value="{!opportunity.CLA_Type__c}"/> <apex:inputField value="{!opportunity.type}"/> <apex:inputField value="{!opportunity.Parent_Opportunity__c}"/> <apex:inputField value="{!opportunity.House__c}"/> <apex:inputField value="{!opportunity.closedate}"/> <apex:inputField value="{!opportunity.probability}"/> <apex:inputField value="{!opportunity.forecastcategoryname}"/> <apex:inputField value="{!opportunity.amount}"/> </apex:pageBlockSection> </apex:actionRegion> </apex:pageBlock> </apex:form> </apex:page>

 

Message Edited by SteveOC on 04-21-2009 04:04 PM
Message Edited by SteveOC on 04-22-2009 01:49 PM
Message Edited by SteveOC on 04-22-2009 04:44 PM
Message Edited by SteveOC on 04-22-2009 04:45 PM
Message Edited by SteveOC on 04-22-2009 04:45 PM
Message Edited by SteveOC on 04-22-2009 04:46 PM
Message Edited by SteveOC on 04-23-2009 09:41 AM
Message Edited by SteveOC on 04-23-2009 09:41 AM
CliffyCliffy

Hi Steve,

 

Did you find a solution to your problem? i am having the same issue.

 

Cheers

 

Cliff

Ad.baylesAd.bayles

I am having the same issue, since I override the Opportunity detail page by a custom visualforce page.

 

As you can still link probability to stage with simple workflow rules, you cannot access the ForecastCategoryName field directly though the standard interface. It seems like the only way to bypass the problem is to create a trigger on Opportunity ;something like :

trigger TieStagetoForecastCat on Opportunity (before update) {

for (Opportunity opp : Trigger.new){
if(opp.StageName =='Closed Lost'){
opp.ForecastCategoryName = 'Omitted';
}
if(opp.StageName =='Closed Won'){
opp.ForecastCategoryName = 'Closed';
} etc.
}
}

 

I think that it will do the job. If anyone has a better solution (easier to setup and maintain), I'm your man!

ram4SFDCram4SFDC

if trigger is the only way, then why hardcode in trigger. Maintain the relationship via Custom setting. The code would reduce to fewer lines.