Advertisement
Guest User

Untitled

a guest
May 27th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. public void PopulateContactFieldsInQuote(list<Quote> quotelist1){
  2.  
  3. List<Quote> quoteList = new List<Quote>();
  4. Map<String, Quote> QuotetoOpportunityIDMap = new Map<String, Quote>();
  5. for( Quote Qid : quotelist1 )
  6. {
  7. QuotetoOpportunityIDMap.put( Qid.OpportunityID, Qid );
  8. }
  9.  
  10. List<OpportunityContactRole> Contactlist = [select OpportunityID, IsPrimary,ContactID,contact.email,contact.phone,contact.fax from OpportunityContactRole where OpportunityID in :QuotetoOpportunityIDMap.keySet() and IsPrimary = true];
  11.  
  12. for (OpportunityContactRole oppConrole : Contactlist) {
  13.  
  14. Quote quoteToUpdate = QuotetoOpportunityIDMap.get(oppConrole.OpportunityID);
  15.  
  16. quoteToUpdate.ContactId = oppConrole.ContactId;
  17. quoteToUpdate.phone = oppConrole.Contact.phone;
  18. quoteToUpdate.fax = oppConrole.Contact.fax;
  19. quoteToUpdate.email = oppConrole.Contact.email;
  20. quoteList.add(quoteToUpdate);
  21. }
  22. }
  23.  
  24. contact c=new contact();
  25. c.lastname='ctes';
  26. c.accountid=a.id;
  27. insert c;
  28.  
  29. opportunity o = new opportunity();
  30. o.name = 'Testoppty';
  31. o.StageName = 'lead';
  32. o.CloseDate = date.today();
  33. o.accountid = a.Id;
  34. o.Billing_Type__c='Aggregate';
  35. insert o;
  36.  
  37. quote q=new quote();
  38. q.name='tesq';
  39. q.contactid=c.id;
  40. q.email='g@gg.com';
  41. insert q;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement