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
naveen reddy 68naveen reddy 68 

My Question is based on trigger, I have two date fields by calculating the difference between two fields it has to create the records on the same object

 In this program the for loop is not working
trigger calculation on calculation__c (before insert,before update) 
{
  list<calculation__c>cal1=new list<calculation__c>();
    for(calculation__c cal:trigger.new)
    { 
        
        integer intDays =  cal.Open_date__c.daysBetween(cal.closed_date__c);
       system.debug(intDays);
      if(intDays!=null)
        {
          
              
        for(integer i=1;i<=intDays;i++)
        {
           
           for(calculation__c cl:trigger.new)
           {                    
               if(trigger.isInsert)
               {
                cal.customer_Name__c='naveen';
                   cal1.add(cal); 
               }
                //insert cal1;
               
               
          }
        }
        }    
       }
    }