+ Start a Discussion
Russell baker 1Russell baker 1 

Want to add all opportunities into Custom Object(Budget) realted list according to closed date.

Hi, I created a custom object budget which will store company budget for every month. i created opportunity related list into budget and I want to show all opportunities into that related list according to close date.
Let say if any opportunity close date is Jan so it should be show under Jan budget.
How can I achieve this do I need to create trigger to pull all opportunities into budget related list.

Please suggest.
salesforce mesalesforce me
hi this is sample code check this once...

not releated
trigger IMP on Opportunity (after insert) { 
 List <implementation__c> ImpToInsert = new List <implementation__c> ();

 for (Opportunity o : Trigger.new) 
 {
   implementation__c rec = new implementation__c (implementation__c = o.id); 
   ImpToInsert.add(rec);
 }

database.saveResult[] sr = database.insert(impToInsert,false);  

 for(integer x=0;x<sr.size();x++)
 {
	if(sr[x].isSuccess() == false)
      system.debug(logginglevel.error,sr[x].getErrors()[0].getMessage());
 }
}

 
Russell baker 1Russell baker 1
Nops, It is not working. I will create budget ecery month and opportunity should be show under related list on that month on which month opportunity close date set.
Russell baker 1Russell baker 1
User-added image
I want to pull all opportunities whos closed date in Jan  under opportunity related list.
Please help!