1

Background

According to the Triggers and Order of Execution documentation:

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.

Which means a child record change causes parent object to trigger.

I have an Invoice__c object and child Invoice_Line__c object.

Questions

  1. Is there any way to determine if the Invoice__c trigger was fired due to a Invoice_Line__c record change? (without adding a Invoice Line Count roll-up summary field)
3
  • You could place a system.debug statement in the code to see if you are ever in doubt.
    – bemon
    Commented Aug 1, 2019 at 13:36
  • Is there any existing rollup-summary? Commented Aug 1, 2019 at 13:42
  • @PranayJaiswal there isn't
    – Robs
    Commented Aug 1, 2019 at 13:51

1 Answer 1

2

You can do it using a Static variable in some class.

InvoiceLineTrigger :

Trigger InvoiceLineTrigger on Invoice_Line__c (){

    TransactionClass.isInvoiceLineTriggerCalled = true;

}

TransactionClass :

public class TransactionClass{

    public static boolean isInvoiceLineTriggerCalled = false;

}

InvoiceTrigger :

Trigger InvoiceTrigger on Invoice__c (){

    if(TransactionClass.isInvoiceLineTriggerCalled){ // Parent update due to child

    }

}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .