Hi Doyeli,
This post is really helpful. I am trying this out to default a value on Invoice owner from opportunity object. I am able to default the value and show to the end user. However its not getting saved under Quote. zqu__InvoiceOwnerName__c or zqu__InvoiceOwnerId__c.
Here is the code snippet. Can you please help what is wrong here?
global class DefaultValuesPlugin extends zqu.CreateQuoteController.PopulateDefaultFieldValuePlugin { global override void populateDefaultFieldValue (SObject record, zqu.PropertyComponentController.ParentController pcc) { super.populateDefaultFieldValue(record, pcc); //Populate default values in the quote header // Retrieve the account ID from the quote Id oppId = (Id) record.get('zqu__Opportunity__c'); System.debug('Opportunity id: '+ oppId); // Find the contacts associated with the account List<Opportunity> OppList = [SELECT Id,AccountId,Name,Invoice_Owner__c,End_User__c from Opportunity where Id =: oppId]; System.debug('OppList values: '+ OppList); Set<Id> InvId = new Set<Id>(); if (OppList.size() > 0) { InvId.add(OppList[0].Invoice_Owner__c); record.put('zqu__InvoiceOwnerId__c',OppList[0].Invoice_Owner__c); //record.put('zqu__InvoiceOwnerName__c',OppList[0].Invoice_Owner__c); record.put('End_User__c',OppList[0].End_User__c); } List<Zuora__CustomerAccount__c> BillingAcntList = [SELECT Id,Name from Zuora__CustomerAccount__c where Id =: InvId]; if(BillingAcntList.size()>0) { record.put('zqu__InvoiceOwnerName__c',BillingAcntList[0].Name); } System.debug('BillingAcntList: '+ BillingAcntList) super.populateDefaultFieldValue(record, pcc); } }
... View more