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 

issue in script running

Hi all,

Here is script to create related record for opprtunity for month jan,feb,march but its not working. please help me to solve it.


//Script
MapId, Opportunity oppItems = new MapId, Opportunity();
    listARRCalcualateOpportunity__c Arropplist= new listARRCalcualateOpportunity__c();
    for(opportunity oppTrigger.New){
        if(opp.StageName == 'closed Won')  
        {
          oppItems.put(opp.Id, opp);
        }
    }
    
    ListOpportunityLineItem oliList = [select Id,Name,Product2Id,Product2.Family from 
                                 OpportunityLineItem where OpportunityId IN  oppItems.keySet()];
        
        for(OpportunityLineItem oli  oliList){
            if(oli.product2.family == 'software Recurring__c')
            {
              ARRCalcualateOpportunity__c arrOpp = new ARRCalcualateOpportunity__c();
              arropp.name = oppItems.get(oli.OpportunityId).Name;
              arropp.ownerId = oppItems.get(oli.OpportunityId).OwnerId; 
              arropp.OpportunityArr__c=oppItems.get(oli.OpportunityId).Id;   
              Arropplist.add(arropp);
            }
        }
        
        if(Arropplist.size()  0){
          insert Arropplist;
        }
    }
}