Activity Forums Salesforce® Discussions Update Parent Record from a Salesforce trigger

  • Update Parent Record from a Salesforce trigger

    Posted by Nitish on April 30, 2016 at 5:09 pm

    I have been trying to come up with the pattern in which I need to handle the below scenario ( considering recursion ).

    On Insertion of Child Record ( Object - B ) I need to update parent record ( object - A) as well as conditionally insert an object ( object - B again ).

    Could anyone point me what is the best way to handle this kind of scenario?

    ** EDIT **

    Sorry if it is confusing. Giving another shot 🙂

    Initially Insert record for Object B ( consider of type Apple), after that update Object A and then based on some criteria create new records for Object B ( this time it might be Mango and Orange ) again after that need to update Object A.

    Ajay Prakash replied 6 years, 9 months ago 3 Members · 2 Replies
  • 2 Replies
  • Prakhar

    Member
    June 13, 2016 at 12:22 pm

    Hii Nitish,

    You can definetly update the parent record when an child record is inserted using triggers. For this you will have to write a trigger on child and when child is inserted you can get the parent record of the child and then update that particular record.

    Can you please explain your conditions so that I could come up with the exact solution.

    Thanks.

  • Ajay Prakash

    Member
    February 18, 2018 at 6:05 am

    In this scenario, if criteria are met every time a parent record is updated means you will insert a new child record, it will exceed the maximum depth limit of a trigger and will throw a maximum trigger depth exception.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos