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
madhan bondalapatimadhan bondalapati 

I have one feild on opportunity ,it is checked the record should not be edited

I wrote trigger like this ,but it is showing some error.Could anyone help in this

trigger DisableEdit on Opportunity (before update)
{
   Set<Id> parentIds=new Set<Id>();
   for(Opportunity opp : Trigger.old)
   {
            parentIds.add(opp.Id);
   }   
    Map<Id, Opportunity> parentMap=new Map<Id, Opportunity>();
   parentMap.putAll([Select Id from Opportunity where Oppty_Status__c = 'Closed' and Id in :parentIds]);
     for(Opportunity opp : Trigger.old)
    {
            if (parentMap.get(opp.Id)!= null)
      {
               opp.addError('You don\'t have Previlege to Edit a Renewal after status is set to Closed');
               
      }

    }           
}

It is showing error message at the opp.adderror.When i checked the debug log it is not passing that line