+ Start a Discussion

Sum of record value

Hi All
How can i sum the last record value with new one.For example i have created a record with field value 400.again i  create another record with filed value 500 ,then how i will add this field value like 400+500=900 in second record  and so on..
Salesforce seekarSalesforce seekar
hi , 

use this code accordingly, ie displaying several  Amount__c  values  of contacts and sending the total to Account

acclist =[select id,name,Total_Amount__c,(select id, name ,Amount__c from contacts) from Account where id in: AccID];
  for(Account acc  :acclist )
  integer sum =0; 

        for(contact cont : acc.contacts)
           sum += cont.Amount__c ;
        acc.Total_Amount__c= val;