0

I'm getting a Variable does not exist:Trigger error on this trigger. What am I doing wrong in the code? Please assist

trigger calcClaim on Claim__c (after Insert, after Update, Before Delete){
set<Id> OccIds = new set<Id>();
    integer count = 0;
    for(Claim__c cl :(Trigger.IsDelete ? Trigger.old: Trigger.new) )
    {    
        decimal temp = 0.0;
        try{
          if(Trigger.IsDelete || Trigger.IsInsert || (Trigger.IsUpdate && cl.Initial_Estimate__c != Trigger.oldMap.get.(cl.id).Initial_Estimate__c))
       {
                OccIds.add(cl.Occurrence__c);
       }
     }
          Catch(exception e)
         {
    cl.adderror(e.getMessage());
         }
  } 

if(!(OccIds.isempty())){
    List<RK_Occurrence__c> occs  = ([SELECT id FROM RK_Occurrence__c where Id in :OccIds]);
    system.debug(occs);

    OccurenceClaimCalculator.calculateOcc(occs);
    }
}
1
  • 3
    Do quote (cut and paste) the full error message in your questions: the details often matter.
    – Keith C
    Commented Feb 4, 2020 at 11:03

1 Answer 1

8

You have a typo:

Trigger.oldMap.get.(cl.id).Initial_Estimate__c

should be:

Trigger.oldMap.get(cl.id).Initial_Estimate__c

You probably also need to apply an explicit cast, like:

((Claim__c) Trigger.oldMap.get(cl.id)).Initial_Estimate__c

You'll find this sort of issue easily by using an appropriate IDE. For example, I found it be copy/pasting your code into the anonymous apex tool provided by Illuminated Cloud. Other IDEs may be able to help you similarly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .