Happy Business Starts Here

Trying to make the default renewal setting to Renew To Evergreen, need help with my apex class.

Highlighted
Master

Trying to make the default renewal setting to Renew To Evergreen, need help with my apex class.

I'm trying to get the default renewal setting to be "Renew To Evergreen" instead of "Renew With Specific Term." I cannot seem to figure it out and I was hoping someone could help me with my apex class.  All of the other field updates are working correctly.

 

global class DefaultValues 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  
      record.put('zqu__ValidUntil__c', Date.today().addDays(30));   
      record.put('zqu__StartDate__c', Date.today());   
      record.put('zqu__PaymentMethod__c', 'ACH');
      zqu__quote__c myQuote = new zqu__quote__c();
         myQuote.zqu__RenewalSetting__c = 'Renew To Evergreen';

      //Usage only subscription solution
      Id billToContact = (Id) record.get('zqu__BillToContact__c');
      Datetime myTime = Datetime.now();
      String timeStr = myTime.format('MM.dd.yy');   
         try {
         if (billToContact == null) {record.put('zqu__BillCycleDay__c', String.valueOf(myTime.day()));}}
         catch (Exception e) {record.put('zqu__BillCycleDay__c', String.valueOf(myTime.day()));
        }}}
5 REPLIES 5
Guru

Re: Trying to make the default renewal setting to Renew To Evergreen, need help with my apex class.

You should not be creating a quote in this method.

The record parameter already points to the quote.

 

Not 

zqu__quote__c myQuote = new zqu__quote__c();
myQuote.zqu__RenewalSetting__c = 'Renew To Evergreen';

Use 

 record.put('zqu__RenewalSetting__c ', 'Renew To Evergreen');
Maggie Longshore
Master

Re: Trying to make the default renewal setting to Renew To Evergreen, need help with my apex class.

record.put doesn't work for this, which was the first thing I tried.

Support SME

Re: Trying to make the default renewal setting to Renew To Evergreen, need help with my apex class.

Hi @sfguy92 following was a working code :

 

 

global class Z_PopulateDefaultFieldValuePlugin extends zqu.CreateQuoteController.PopulateDefaultFieldValuePlugin{ 
global override void populateDefaultFieldValue(SObject record, zqu.PropertyComponentController.ParentController pcc) 
{ 
if(!Test.isRunningTest()) 
super.populateDefaultFieldValue(record, pcc);

//Populate default values in the quote header 
record.put('zqu__RenewalSetting__c','RENEW_TO_EVERGREEN'); 
} 
}

Please note

RENEW_TO_EVERGREEN

 






If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

Guru

Re: Trying to make the default renewal setting to Renew To Evergreen, need help with my apex class.

I did not look up the value - I used your code for it - but as Doyeli shows you just need to use the picklist value.

Maggie Longshore
Master

Re: Trying to make the default renewal setting to Renew To Evergreen, need help with my apex class.

I was doing 'Renew To Evergreen' instead of RENEW_TO_EVERGREEN.

 

Thanks!