Start a conversation

Order Generation Batch Not Triggering Due to Custom Code NullPointerException

Symptom

Order generation batch is not being triggered in production. Custom code (AllProductBasketTriggerHelperInt) throws a NullPointerException because billingAccountMap does not contain the basket's Billing_Account__c value.

Cause

Custom trigger helper code does not validate that a billing account ID exists in its lookup map before accessing it. When a basket has a billing account not present in the map, a NullPointerException is thrown, blocking the entire batch.

Resolution

Step 1: Check for async job failures

select Id, CreatedDate, CreatedBy.name, JobType, ApexClass.name, Status, JobItemsProcessed, TotalJobItems, NumberOfErrors, CompletedDate, MethodName, ExtendedStatus, CronTriggerId
from AsyncApexJob
where ApexClass.NamespacePrefix = 'csordtelcoa'
order by CreatedDate desc

Step 2: Identify the failing custom class and line number from the error stack trace

Step 3: Fix the custom code to add a null check: verify that billingAccountMap.containsKey(basket.Billing_Account__c) before accessing the map

Step 4: Query baskets targeted by the telco batch engine

select id from cscfga__Product_Basket__c where csordtelcoa__Process_Order_Generation_In_Batch__c = true and csordtelcoa__Order_Generation_Batch_Job_Id__c = 'None' and (cscfga__basket_status__c in ('Submitted') or csordtelcoa__Basket_Stage__c in ('Submitted'))

Step 5: Temporarily exclude problematic baskets (those with billing accounts not in the map) from the batch engine scope by editing their status, until the custom code fix is deployed

Why a Single NPE Blocks the Entire Batch

The order generation batch engine processes all eligible baskets (those with csordtelcoa__Process_Order_Generation_In_Batch__c = true and status Submitted) within a single batch scope. During processing, the basket trigger framework invokes custom trigger helpers. If a custom trigger helper accesses a map key without a containsKey() guard, the resulting NullPointerException aborts the entire batch scope -- not just the problematic basket. This is why a single basket with an invalid billing account reference can block order generation for all submitted baskets.

Batch execution status is tracked via Batch_Engine_Tracker__c and can be queried via AsyncApexJob with ApexClass.NamespacePrefix = 'csordtelcoa'.

Additional Notes

  • Ensure custom trigger helpers validate map lookups before access to prevent NullPointerException from blocking batch execution.
Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Priyanka Bhotika

  2. Posted

Comments