You need to sign in to do that
Don't have an account?
anil Anil5
trigger RollUpSummaryUpdate on Company__c(after insert,after update){
double totalSum = 0;
Set<Id> Parentids = New Set<Id>();
for(integer i=0;i<Trigger.new.Size();i++){
Parentids.add(Trigger.new[i].Clients__c);
}
List<Client__c> AP = [SELECT ID,(SELECT ID FROM Company__r) FROM Client__c WHERE ID=:Parentids];
for(Client__c apUpdates:AP){
totalSum += Company__c.Amount__c;
apUpdates.Sum__c =totalSum;
}
Update AP;
}
Error: Compile Error: Arithmetic expressions must use numeric arguments at line 15 column 13
trigger RollUpSummaryUpdate on Company__c(after insert,after update){
double totalSum = 0;
Set<Id> Parentids = New Set<Id>();
for(integer i=0;i<Trigger.new.Size();i++){
Parentids.add(Trigger.new[i].Clients__c);
}
List<Client__c> AP = [SELECT ID,(SELECT ID FROM Company__r) FROM Client__c WHERE ID=:Parentids];
for(Client__c apUpdates:AP){
totalSum += Company__c.Amount__c;
apUpdates.Sum__c =totalSum;
}
Update AP;
}
It is because Company__c.Amount__c doesn't exist anywhere. if you are using trigger you will write it as
Though it is not a good practice but I am assuming that you are always updating a single record.
Thanks,
Himanshu
Thanks,
Amit Chaudhary