Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void PopulateContactFieldsInQuote(list<Quote> quotelist1){
- List<Quote> quoteList = new List<Quote>();
- Map<String, Quote> QuotetoOpportunityIDMap = new Map<String, Quote>();
- for( Quote Qid : quotelist1 )
- {
- QuotetoOpportunityIDMap.put( Qid.OpportunityID, Qid );
- }
- List<OpportunityContactRole> Contactlist = [select OpportunityID, IsPrimary,ContactID,contact.email,contact.phone,contact.fax from OpportunityContactRole where OpportunityID in :QuotetoOpportunityIDMap.keySet() and IsPrimary = true];
- for (OpportunityContactRole oppConrole : Contactlist) {
- Quote quoteToUpdate = QuotetoOpportunityIDMap.get(oppConrole.OpportunityID);
- quoteToUpdate.ContactId = oppConrole.ContactId;
- quoteToUpdate.phone = oppConrole.Contact.phone;
- quoteToUpdate.fax = oppConrole.Contact.fax;
- quoteToUpdate.email = oppConrole.Contact.email;
- quoteList.add(quoteToUpdate);
- }
- }
- contact c=new contact();
- c.lastname='ctes';
- c.accountid=a.id;
- insert c;
- opportunity o = new opportunity();
- o.name = 'Testoppty';
- o.StageName = 'lead';
- o.CloseDate = date.today();
- o.accountid = a.Id;
- o.Billing_Type__c='Aggregate';
- insert o;
- quote q=new quote();
- q.name='tesq';
- q.contactid=c.id;
- q.email='g@gg.com';
- insert q;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement