• Jay Srinivasan
  • 0 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2
Hi all, 

I am trying to get my quotes to autosync to the opportunity upon creation.  I have the following controller, trigger, and test class:

public class QuoteAutoSyncUtil
        public static void syncQuote(Map<Id, Id> quoteMap)
            List<Opportunity> oppList = new List<Opportunity>();
            for(Id currentQuote : quoteMap.keyset())
                Opportunity opp = new Opportunity();
                opp.Id = quoteMap.get(currentQuote);
                opp.SyncedQuoteId = currentQuote;

            update oppList;

trigger QuoteAutoSync on Quote (after insert)
        Map<Id, Id> quoteMap = new Map<Id, Id>();
        for(Quote currentQuote : Trigger.New)
              quoteMap.put(currentQuote.Id, currentQuote.OpportunityId);

Test Class:
    private class TestQuoteAutoSync
        static testMethod void insertQuote()
            Opportunity opp = new Opportunity();
            opp.Name = 'Test Opportunity';
            opp.StageName = 'Prospecting';
            opp.CloseDate = system.today();
            insert opp;
            Quote quo = new Quote();
            quo.Name = 'Test Quote';
            quo.OpportunityId = opp.Id;        
            insert quo;
            Opportunity o = [select SyncedQuoteId from opportunity where id=:opp.Id];
            system.assert(o.SyncedQuoteId != null);

It is functioning properly in Sandbox and clears tests with 100% coverage but when I try to push to Production I get the following error with the test class:

System.AssertException: Assertion Failed
Stack Trace: Class.TestQuoteAutoSync.insertQuote: line 21, column 1

*Line 21 = system.assert(o.SyncedQuoteId != null);

Any ideas what I am missing? 



   I have this field (xyz)of type input text area on my visualforce page as <apex:inputField  value ="{!Opportunity.xyz__c}"/>. If i give characters more than the default limit of  text area type, Then it gives an error message , which should happen. But instead of one I am getting two error messages below that field. Can anyone please suggest me a way to rectify this issue?