function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jim MontgomeryJim Montgomery 

Trying to assign a value for SOQL query as variable

Trying to assign extended_maintenance_months__c as the variable months in the definition of addMonths.

trigger SoftwareAnnualEndDates on Apttus_Proposal__Proposal__c (After update) {

    List<apttus_proposal__proposal_line_item__c> lstToUpdate = new List<apttus_proposal__proposal_line_item__c>();

    for(apttus_proposal__proposal_line_item__c obj :[select maintenance_end_date__c, proposal_end_date__c,extended_maintenance_months__c from apttus_proposal__proposal_line_item__c where extended_maintenance_months__c >0 and apttus_proposal__proposal__c != null and apttus_proposal__proposal__c in : trigger.new])
       
    {         
        obj.maintenance_end_date__c = proposal_end_date__c.addMonths(Months);

        lstToUpdate.add(obj);
   }

    if(!lstToUpdate.isEmpty())

        update lstToUpdate;

}
karthikeyan perumalkarthikeyan perumal
Hello, 

use below updated code. 
 
trigger SoftwareAnnualEndDates on Apttus_Proposal__Proposal__c (After update) {

    List<apttus_proposal__proposal_line_item__c> lstToUpdate = new List<apttus_proposal__proposal_line_item__c>();

    for(apttus_proposal__proposal_line_item__c obj :[select maintenance_end_date__c, proposal_end_date__c,extended_maintenance_months__c from apttus_proposal__proposal_line_item__c where extended_maintenance_months__c >0 and apttus_proposal__proposal__c != null and apttus_proposal__proposal__c in : trigger.new])
       
    {         
        obj.maintenance_end_date__c =                              proposal_end_date__c.addMonths(integer.valueof(obj.extended_maintenance_months__c));

        lstToUpdate.add(obj);
   }

    if(!lstToUpdate.isEmpty())

        update lstToUpdate;

}

Hope this will help you

Thanks
karthik

 
Jim MontgomeryJim Montgomery
Thank you!! Jim Montgomery Manager, Sales Intelligence Operations Wolters Kluwer Tax & Accounting 20101 Hamilton Ave. Torrance, CA 90502 877-346-7148 jim.montgomery@wolterskluwer.com