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
Sujitha VedagiriSujitha Vedagiri 

Need help-opportunity trigger to overcome two record insertion in stage history with close date as 31/5/2017

I have written a trigger on opportunity with close date as 31/5/2017 and in stage history it is showing one record as per the stage when i change the stage one more record is inserting. i want only one record to be inserted in stage history with 31/5/2017.
Here is my code.

trigger updateclosedate on Opportunity (before insert) 
{
List<id> ids=new List<id>();

for(Opportunity A : trigger.new)
ids.add(A.id);
//List<Opportunity> opupdate=new List<Opportunity>();
list<opportunity> opupdate=[SELECT Id,closedate FROM Opportunity WHERE CloseDate = NEXT_FISCAL_YEAR];
for(Opportunity o: opupdate)
{
 
 opupdate.add(o);
 system.debug('opupdate333333'+opupdate);
}
insert opupdate;

}

Can you please help on this.