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
DolgoldyDolgoldy 

Script not running

Hi all,
Here is my script to update opprtunity record on reled object for 3 month but its not creating record plz help me

script


 list<opportunity> opplist  =new list <opportunity>();  
 List <ARRCalcualateOpportunity__c> ArroppList = new List <ARRCalcualateOpportunity__c>();
    for (Opportunity oppobj : opplist) 
    {
       
        if (oppobj.StageName == 'Closed Won' && oppobj.closedate.month()>=1 && oppobj.closedate.month<=3)
        {  
            for(OpportunityLineItem Oli:[select Id,Name,Product2Id,Product2.Family from
                                         OpportunityLineItem where OpportunityId=:oppobj.Id])
            {
                
                 if(oli.Product2.Family =='Software Recurring')
                     
                 {
                     // To display date in asscending order
                   Date dt = oppobj.closedate;
                     for(Integer i =0;i<12;i++)
                    {
                        ARRCalcualateOpportunity__c arrObj = new ARRCalcualateOpportunity__c(); 
                      arrobj.ARRdate__c = oppobj.CloseDate;
                        //will display 12 date in ascending order
                     arrobj.ARRdate__c  =dt.addMonths(i);
                       arrobj.Name = oppobj.name;
                        arrobj.oppAmount__c = oppobj.Amount;
           List<OpportunityLineItem> oppli= [select Id from OpportunityLineItem 
                                              where OpportunityId = : oppobj.Id];
                       
                        arrobj.Opportunity_Product__c = oppli[0].id;
                       arrobj.OpportunityArr__c= oppobj.Id;                        
                        ArroppList.add(arrobj);
                        
                    }
                         
                   }   
            }
        }
    
    }
if(arropplist>0){

 insert ArroppList;
}
   
 
SwethaSwetha (Salesforce Developers) 
HI Dolly,
Have you tried setting up debug logs to see what is being fetched in arrobj before it is added to ArroppList? Do you see any errors while execution?
Thanks
DolgoldyDolgoldy
Hi yes i checked logs there is nothing in the list. and didn't show any error