You need to sign in to do that
Don't have an account?
Anthony Suda RM
We have the Closed Won stage set at 100% Probability. If we manually move the Oppty to Closed Won and save, the Probability updates to 100% jsut fine. But when using the code below, it updates the stage correctly but the Probability remains where it was. We have this working in our Prod instance, but we're attempting some stage renames (probabilities staying the same - and not changing Closed Won), but it's not updating the Probability field.
Updating Opportunity to Closed Won via APEX doesn't update Probability to match 100%
private Opportunity currentOpp; public ConvertOppToProjectControllerExtension(ApexPages.StandardController stdController) { this.currentOpp = (Opportunity)stdController.getRecord(); } public ConvertOppToProjectControllerExtension(Opportunity currentOpp) { this.currentOpp = currentOpp; } currentOpp = [SELECT Id, Abbreviation__c, AccountId, CloseDate, Name, OwnerId, Probability, Description, StageName, Portfolio__c, NextTaskNumber__c, Company__c, Service_Type__c, AM_Sales_Ops__c, (SELECT Name, Approved__c, Opportunity__c, Estimate_Total_Dollars__c FROM Estimates__r) FROM Opportunity WHERE Id = :currentOpp.Id]; //Convert the Opportunity itself currentOpp.StageName = 'Closed Won'; currentOpp.CloseDate = System.now().date(); Database.update(currentOpp);
We have the Closed Won stage set at 100% Probability. If we manually move the Oppty to Closed Won and save, the Probability updates to 100% jsut fine. But when using the code below, it updates the stage correctly but the Probability remains where it was. We have this working in our Prod instance, but we're attempting some stage renames (probabilities staying the same - and not changing Closed Won), but it's not updating the Probability field.
The probability field is directly linked to the stage value selected, however, the probability can be manually edited by users who have edit access to this field. Since Salesforce allows this, it means that the probability value doesn't act as a fixed value, instead, it works as a default value.
For example, if you choose Closed/Won on the stage, Salesforce will give you a default value of 100%, but you can manually edit this value to 57% for example.
Because of this, when you change the probability linked to a stage value under Setup, existing opportunities will not show the new probability value, since the probability was already saved on the record before the change. If you then go to one of these opportunities and manually change the stage, you will now see its new default value now you can select it too.
Hope this helps !!
--
Thanks,
Swayam
Can you try running the below query in your code and checking the probability there :
I won't remain same, unless there is some code in the trigger that is updating it to the old probability.
We've setup dozens of Salesforce Orgs in the past with custom integrations and code and have never seen this happen before. Oppty Stage change always updates Probability to match... now all of a sudden it's not, and we can't find the answer as to why.
What I would suggest is to refer the debug logs closely to see at what point the value is getting manipulated.
Did you find a solution to your problem? I'm seeing something like this with Auctions for Salesforce when updating an opportunity at checkout. Could be something completely different, but I'm stumped.