Activity Forums Salesforce® Discussions When RollUp Summary field value changes, is any trigger is fire on Parent object?

  • When RollUp Summary field value changes, is any trigger is fire on Parent object?

    Posted by Avnish Yadav on September 12, 2018 at 9:09 am

    When RollUp Summary field value changes, is any trigger is fire on the Parent object? Please Explain

    Parul replied 6 years, 2 months ago 3 Members · 2 Replies
  • 2 Replies
  • shariq

    Member
    September 12, 2018 at 12:15 pm

    Hi,

    The Trigger will fire.The Document mentions that the Parent record record goes through save procedure meaning the trigger will fire on parent record if there is a modification on the field of child record that feeds to the parent as roll up.

    Hope this helps!

  • Parul

    Member
    September 12, 2018 at 4:01 pm

    Hi Avanish,

    If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the parent record. Parent record goes through save procedure. So, updating the child inputs to a roll-up summary field can cause a trigger on an object to fire.

    Consider the following example with a Master detail between Child and Parent and the following:

    • Number field on Child called Num Field
    • Roll-up summary on Parent that sums Num Field

    Write the following trigger on Parent__c:

    trigger ParentTrigger on Parent__c (before update) {
    for (Parent__c p : Trigger.New) {
    p.addError('Not going to save');
    }
    }

    Now go into the new or edit page for your Child object and fill in a value for Num Field and save the record and see what happens. You get:

    Error: Invalid Data.

    Review all error messages below to correct your data.

    Not going to save

    Next, blank out the Num Field and save and see what happens. No error is generated and the Childsaves.

    So when the child record is saved and the field feeds into the roll-up summary the parent trigger is executed.

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos