Question 1 : I am stuck while updating the custom object field(salary_c)
trigger TotalTheValue on Appointment__c (after insert, after update) {
public decimal Sum;
list <decimal> tt =new list <decimal>();
List<Appointment__c> ap = new List<Appointment__c>();
List<Appointment__c> app = new List<Appointment__c>();
app = [Select Salary__c ,total__c from Appointment__c where RecordTypeId='0122v000001c9OP'];
if (app.size() > 0) {
for ( Appointment__c c:app){
c.Salary__c=300;
system.debug('the value is app ' + c );
ap.add(c);
} }
update ap;
}
but its show an error
Update failed. First exception on row 0 with id a0x2v00000t6uJBAAY; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TotalTheValue: maximum trigger depth exceeded Appointment trigger event AfterUpdate Appointment
how to fix this??
Question 2: I have two fields (total_cost__c and daily_cost__c) on custom object.I want to sum daily_cost__c of all records of that object and show the total value in total_cost__c ?