Overview
When creating an Extension Period MACD order in Salesforce (including via anonymous Apex) using csordtelcoa.API_V1.addSubscriptionsToMacOpportunity(List<Id> subscriptionIds, Id opportunityId, Boolean processAsync), the transaction may fail with System.NullPointerException: Attempt to de-reference a null object in the csordcb namespace.
A confirmed cause is an invalid CloudSense observer registration: a record in csordcb__Observer__mdt references an Apex class name in csordcb__Class_Name__c that does not exist in the org. Correcting or removing the invalid observer entry allows the MACD flow to complete successfully.
Solution
Error Signature
You may see an exception during Extension Period MACD / new order creation such as:
System.NullPointerException: Attempt to de-reference a null object(namespacecsordcb)
Often reported while calling:
csordtelcoa.API_V1.addSubscriptionsToMacOpportunity(List<Id> subscriptionIds, Id opportunityId, Boolean processAsync)
When This Occurs
This pattern can occur during CloudSense observer processing, where CloudSense loads observer registrations from custom metadata and attempts to instantiate and dispatch them.
Root Cause (Confirmed)
An entry in the CloudSense Observer custom metadata type csordcb__Observer__mdt contains a value in csordcb__Class_Name__c that references an Apex class not present in the org.
Example observed: CSMassMacdJobStatusHandler was referenced by an observer record, but the Apex class did not exist.
Diagnosis
-
Run the following SOQL query (Developer Console / VS Code + Salesforce extension / Workbench):
select Id, DeveloperName, csordcb__Class_Name__c from csordcb__Observer__mdt order by SystemModstamp desc -
For each returned
csordcb__Class_Name__cvalue, verify the Apex class exists in the org (Setup → Apex Classes, or by queryingApexClassby name). -
Identify any observer entries where
csordcb__Class_Name__cis populated but the corresponding Apex class is missing.
Resolution
Choose the option that best matches your implementation.
Option A (Common): Remove or Correct the Invalid Observer Registration
- Go to Setup → Custom Metadata Types.
- Locate the type Observer (API name:
csordcb__Observer__mdt) and open Manage Records. - Find the observer record whose
csordcb__Class_Name__cpoints to a missing Apex class. - Delete that custom metadata record, or update it to reference a valid class (if appropriate for your configuration).
- Retry the Extension Period MACD action or re-run
addSubscriptionsToMacOpportunity(...).
Option B: Restore/Deploy the Missing Apex Class
If the observer is expected to run in your org (for example, it is part of a customization package you maintain), deploy/restore the missing Apex class so it matches the metadata registration, then retry the MACD flow.
Verification
- Re-run the same operation that previously failed (UI-driven Extension Period MACD order creation, or the same anonymous Apex invocation of
csordtelcoa.API_V1.addSubscriptionsToMacOpportunity(...)). - Confirm the process completes without
System.NullPointerException: Attempt to de-reference a null objectin thecsordcbnamespace.
Notes / Cautions
- Only remove an observer registration if it is not required for your business flow. If it is required, restoring the missing class is typically the safer approach.
- If behavior differs across orgs (for example, UAT works but a sandbox fails), compare
csordcb__Observer__mdtrecords and the presence of referenced Apex classes across those orgs.
Frequently Asked Questions
- 1. How can I tell if my null pointer is caused by observer metadata?
-
If the error is
System.NullPointerException: Attempt to de-reference a null objectin namespacecsordcbduring MACD/order creation, run:select Id, DeveloperName, csordcb__Class_Name__c from csordcb__Observer__mdt order by SystemModstamp descThen confirm every
csordcb__Class_Name__cexists as an Apex class in the org. Any missing class is a strong indicator. - 2. What do I do if I find an observer pointing to a missing class?
-
Either (1) remove/update the corresponding
csordcb__Observer__mdtrecord so it no longer references the missing class, or (2) deploy/restore the missing Apex class (preferred if the observer is needed). - 3. What if all classes referenced in
csordcb__Observer__mdtexist, but the error persists? -
Capture a fresh debug log for the failing transaction and proceed with deeper analysis of the
csordcbobserver dispatch path. Include the output of the observer query above and the timestamp of the failing run. - 4. How do I verify the fix worked?
-
Re-run the same Extension Period MACD flow (or the same
addSubscriptionsToMacOpportunity(...)call) and confirm the transaction completes without thecsordcbnull pointer exception.
Matej Storga
Comments