Contents
Overview
When generating a document in CloudSense Document Generator (reported on package version R35), you may see a null-reference error when clicking Generate (often on a specific record type/DocConfig). This typically occurs when the DocConfig’s Data Source hierarchy is internally inconsistent—specifically, a Data Source in the DocConfig references a parent Data Source (csdg__Parent_Data_Source__c) that is not included in the same DocConfig.
Correcting the Data Source ↔ parent Data Source relationships within the affected DocConfig resolves the null-object failure during Generate.
Error message (verbatim):
Attempt to de-reference a null object
Error is in expression '{!generate}' in component in page cs_documentgenerator: (csdg)
Class.CS_DocumentGeneratorController.generate: line 31, column 1
An unexpected error has occurred. Your solution provider has been notified. (csdg)
Solution
Issue
Document generation fails from the CloudSense document generator UI with the (csdg) null reference error shown above.
When this typically happens
This can appear suddenly (even if the template “worked before”) when a DocConfig’s Data Source tree becomes invalid—for example, a Data Source is linked to the DocConfig but its configured parent Data Source is not part of that same DocConfig.
Root cause
A Data Source referenced by the impacted DocConfig has:
csdg__Parent_Data_Source__cpopulated, but- the referenced parent Data Source is not linked to the same DocConfig (i.e., the parent is “outside” the DocConfig’s Data Source set).
This inconsistency can cause the generator’s Apex logic to hit a null object while building/traversing the Data Source hierarchy (for example, in Class.CS_DocumentGeneratorController.generate).
How to diagnose (SOQL)
Run the following query to list Data Sources used by a specific DocConfig and expose their parent references:
SELECT Id, csdg__Parent_Data_Source__c
FROM csdg__Data_Source__c
WHERE Id IN (
SELECT csdg__Data_Source__c
FROM csdg__DocConfig_Datasource__c
WHERE csdg__Doc_Config__c = '<doc_config_id>'
)
What to look for
For any row where csdg__Parent_Data_Source__c is not null:
- Verify the parent Data Source Id is also linked to the same DocConfig (via
csdg__DocConfig_Datasource__c). - If the parent is not linked to the same DocConfig, that relationship is a likely trigger for the (csdg) null-object error.
Resolution (configuration/data correction)
Apply one of the following corrections so the Data Source hierarchy is consistent within the DocConfig (no version patch is required when the issue is caused by this configuration/data mismatch):
-
Add the missing parent Data Source to the same DocConfig
- Ensure the parent Data Source referenced by
csdg__Parent_Data_Source__cis linked to the DocConfig (create/fix the relevantcsdg__DocConfig_Datasource__crelationship).
- Ensure the parent Data Source referenced by
-
Or, correct/remove the invalid parent reference
- Update the child Data Source so
csdg__Parent_Data_Source__cpoints to the correct parent within the same DocConfig, or - Clear
csdg__Parent_Data_Source__cif that Data Source should not have a parent.
- Update the child Data Source so
Goal: Every csdg__Parent_Data_Source__c used in a DocConfig must resolve to a parent Data Source that is also included in that same DocConfig.
Validation
- Return to the affected Contract (or the same record type that was failing).
- Click the Generate action again.
- Confirm the document generates successfully and the UI no longer displays the (csdg) “Attempt to de-reference a null object” error.
Frequently Asked Questions
- 1. How do I know this is the same issue?
-
You see the exact error mentioning Document Generator and Apex:
Attempt to de-reference a null object ... page cs_documentgenerator (csdg) ... Class.CS_DocumentGeneratorController.generate ...and it occurs consistently for a particular DocConfig/record type.
- 2. Why would this fail now if it worked previously?
-
The DocConfig/Data Source linkage can become inconsistent over time (for example, a parent Data Source was removed from the DocConfig, replaced, or referenced incorrectly). Even without template edits, a broken parent-child relationship in Data Sources can cause generation to fail.
- 3. What is the quickest check to find the mismatch?
-
Run the provided SOQL for the impacted
<doc_config_id>and review Data Sources wherecsdg__Parent_Data_Source__cis populated; confirm each parent is also linked to the same DocConfig. - 4. What if I fix the parent relationship and it still fails?
-
Re-check for additional Data Sources in the same DocConfig that reference parents outside the DocConfig, and confirm the Generate action is using the intended DocConfig/template for that record type. If the error persists, capture the failing DocConfig Id and failing record id and re-run the diagnosis query for that DocConfig.
Matej Storga
Comments