I have a custom object called AppDoc__c which has a master-detail relationship with Case.

I have a process builder on case which creates 3-records of AppDoc__c everytime a new case is created.

Value of Child records:

Case - Field Reference - Case.Id

Now, I have an after Insert trigger on AppDoc__c, which uses the case field of AppDoc__c. But I am getting an error

Can’t Save Record

We can't save this record because the “New AppDoc Upon Case Creation” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to create records:

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: AppDocTrigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Class.AppDocHandler.push: line 6, column 1 AppDocTrigger: line 21, column 1. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1143198561-45111 (378836202)

Here the line of the AppDoc Handler that is throwing the error is actually the line accessing the Case field of AppDoc.

I am not exactly sure why this error is happening, as Process Builder on Case should create the AppDoc with corresponding Case Id, before it is accesses by Case.

  • Can you post process builder screenshot? It will help us debug. May 22, 2018 at 16:33

1 Answer 1


Since the creation of the case and the AppDoc__c records happen in the same transaction you have to worry about order of execution. If you refer to the order of execution link below, after triggers (step 7) execute before process builder (step 13).


You have two options: - After insert trigger on case for creation of the AppDoc__c records. This way the after insert on Case will run before after insert on AppDoc__c records and the code will work. - Invocable method (Apex Action) after the action of creating the records in the process builder. This will require some change in logic to pass allowable values to the invocable method.

I like the first option better since you can control your order of execution.

You must log in to answer this question.

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