You need to sign in to do that
Don't have an account?
Dolgoldy
script not running plz help
Hi,
Here is my script written in anonymous window to create record against opportuniyt for 3 month jan,feb,march but its not working please help me to solve
Map <Id, Opportunity> oppItems = new Map <Id, Opportunity>();
list<ARRCalcualateOpportunity__c> Arropplist= new list<ARRCalcualateOpportunity__c>();
list<Opportunity> opplist= new list<Opportunity>();
for(opportunity opp:opplist){
if (opp.StageName == 'Closed Won'&& opp.closeDate.month() >=1 && opp.closeDate.month() <=3 )
{
oppItems.put(opp.Id, opp);
}
}
List<OpportunityLineItem> oliList = [select Id, Name, Product2Id, Product2.Family,opportunity.amount,opportunity.closedate from
OpportunityLineItem where OpportunityId IN:oppItems.keyset()];
system.debug('oli'+ oliList);
for(OpportunityLineItem oli :oliList)
{
for(Integer i =1;i<=12;i++)
{
if(oli.product2.family == 'software Recurring')
{
ARRCalcualateOpportunity__c arrOpp = new ARRCalcualateOpportunity__c();
arropp.name=string.valueOf(oli.opportunity.closedate);
arropp.OpportunityArr__c= oli.OpportunityId;
arrOpp.Opportunity_Product__c= oli.product2Id;
system.debug('arropp'+arropp);
Arropplist.add(arropp);
}
}
}
if(Arropplist.size() >0){
insert Arropplist;
System.debug('arropp list'+arropplist);
}
Here is my script written in anonymous window to create record against opportuniyt for 3 month jan,feb,march but its not working please help me to solve
Map <Id, Opportunity> oppItems = new Map <Id, Opportunity>();
list<ARRCalcualateOpportunity__c> Arropplist= new list<ARRCalcualateOpportunity__c>();
list<Opportunity> opplist= new list<Opportunity>();
for(opportunity opp:opplist){
if (opp.StageName == 'Closed Won'&& opp.closeDate.month() >=1 && opp.closeDate.month() <=3 )
{
oppItems.put(opp.Id, opp);
}
}
List<OpportunityLineItem> oliList = [select Id, Name, Product2Id, Product2.Family,opportunity.amount,opportunity.closedate from
OpportunityLineItem where OpportunityId IN:oppItems.keyset()];
system.debug('oli'+ oliList);
for(OpportunityLineItem oli :oliList)
{
for(Integer i =1;i<=12;i++)
{
if(oli.product2.family == 'software Recurring')
{
ARRCalcualateOpportunity__c arrOpp = new ARRCalcualateOpportunity__c();
arropp.name=string.valueOf(oli.opportunity.closedate);
arropp.OpportunityArr__c= oli.OpportunityId;
arrOpp.Opportunity_Product__c= oli.product2Id;
system.debug('arropp'+arropp);
Arropplist.add(arropp);
}
}
}
if(Arropplist.size() >0){
insert Arropplist;
System.debug('arropp list'+arropplist);
}
try with below code.
If this helps, Please mark it as best answer.
Thanks!!
All Answers
try with below code.
If this helps, Please mark it as best answer.
Thanks!!
https://www.mylabcorp.me/
Your code is working but giving error in this line so plz help me to solve this out.
try below code. I don't know why you are using integer for loop for 12 digits inside loop. In my code I commented it. if it is necessary you can uncommented it.
if it is helpful to you, let me know by marking it as best answer.
Thank you