• Anthony Suda RM
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Release Manager
  • Sundog


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
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.

 
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.