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
Balaram AdminBalaram Admin 

how to write trigger update account when ever child object roll up value is updated?

write a trigger on invoice line item(child object) to update account balence as sum fo all associated invoices amount for the account.
child obj:invoice
fields:invioce number,invoice date, invoice amount(rollup), account name(lookup with account)
obj2: invoice line iteam
fields:invoice(MD with invoice),product,quantity,unit price,total price(Formula,Qua*UNT pri)
account coustem field: account balance(currency data type)
I didn't understand your requirement clearly. Can you elaborate it clearly?

Hi , 

Trigger updateamount on invoicelineitem (after insert){
    List <Account> acclist = new List<Account>();
    List<Id> accIds = new List<id>();
    for(invoicelineitem it :{

    for(account acc: [select id, invoice amount from account where id IN:accIds]) {
           for((invoicelineitem it :{
               if(it.invoice.accountid =={
                       acc.invoiceamount = it.totalprice;

   // update the accounts
    update acclist;

Balaram AdminBalaram Admin
thnq for replying dudu....
krpr dudu....this is my reqr....please need help.....

 1. custom object called invoice with field as
     a.invioce number(auto number)
     b.invioce date( date)
     c.Account Name(lookup with Account)
     d.invioce Amount(Roll up Summary,sumof allitems Price field of invioce Line Items object)
2.custom object called invoice Line Items with field as
    a.Invioce( Master Detail with Invioce)
    b.Product(Lookup with product)
     d.Unit Price(Currency)will contain price of one product
    e.Total Price((Formula, Quantity*Unit Price

My requirement:
Creat a  trigger on invoice line item to update account balence as sum fo all associated invoices amount for the account.(Create a custom field on Account Called "Account Balance" as currency data type)