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
chiranjib routchiranjib rout 

Error :Line: 1, Column: 0 required (...)+ loop did not match anything at input 'trigger' getting this erron when i run the following trigger immediate suggest

trigger ctcupdate on appointment__c (after insert,after update) {
     appointment__c app;
         Appraisal__c aps;   
    if (aps.amount_of_Increment__c !=0 ||aps.amount_of_Increment__c  !=null){
    app.Current_CTC__c=app.Current_CTC__c +  aps.amount_of_Increment__c ;
        update app;
    }
     if (aps.Increment_Percentage__c !=0 ||aps.Increment_Percentage__c  !=null){  
      app.Current_CTC__c= app.Current_CTC__c + (app.Current_CTC__c * aps.Increment_Percentage__c);
          update app ;
              }
}
Veenesh VikramVeenesh Vikram
You cannot use variable as it is in trigger, you need to use "Trigger.new/trigger.old" to get the values of records under the transaction. so in order to get values in the app variable, iterate on trigger.new.

Also You cannot update the same appointment__c  record from Trigger itself, as salesforce will not allow you to do this, you will have to use @future methods to do the update.
chiranjib routchiranjib rout
The following trigger is working now i can update the CTC but while executing the same error is showing.


trigger CTC_Update on Appraisal__c (after insert,before update ) {
    List<appointment__c> AppList = New List<appointment__c>();
    Set<Id> AppointIds = New Set<Id>();

    For(Appraisal__c A : Trigger.New)
    {
        AppointIds.Add(A.ApplicantName__c);
    }

    List<appointment__c> AppointList = [Select Id,Current_CTC__c from appointment__c where id =: AppointIds];

    For(Appraisal__c Aps : Trigger.New)
    {
        appointment__c A = new appointment__c();

        For(appointment__c App : AppointList)
        {
            IF(Aps.ApplicantName__c == App.ID)
            {
                A.Id = App.Id;

                IF(Aps.amount_of_Increment__c != 0 && Aps.amount_of_Increment__c != NULL)
                {
                    A.Current_CTC__c = App.Current_CTC__c + Aps.amount_of_Increment__c ;
                }
                IF(Aps.Increment_Percentage__c != 0 && Aps.Increment_Percentage__c != NULL)
                {
                    A.Current_CTC__c = App.Current_CTC__c + (App.Current_CTC__c * Aps.Increment_Percentage__c);
                }
            }
            AppList.Add(A);
        }
    }

    IF(AppList != NULL)
    {
        Update AppList;
    }

}