Symptom
When clicking the Deal Management button on a basket, the page fails to load and displays the following JavaScript error in the browser console:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'parentId')
The Deal Management interface remains blank or shows a loading indicator indefinitely.
Cause
The findRoot function in the onAfterInitialLoad event handler requires the cscfga__Parent_Configuration__c field to be populated on Product Configuration records. When this field is missing or null, the function attempts to access properties of an undefined object, causing the TypeError.
This typically occurs when:
- Product Configurations are created without proper parent-child relationships
- Data migration or bulk operations skip the Parent Configuration field
- Custom code creates PCs without setting the parent reference
Resolution
Step 1: Identify the Affected Product Configuration
- Navigate to the basket in Salesforce
- Open the browser Developer Tools (F12)
- Go to the Console tab
- Reproduce the error by clicking Deal Management
- Note the Product Configuration ID from the error stack trace or URL
Step 2: Verify the Missing Parent Configuration Field
Run the following SOQL query to check the Parent Configuration field:
SELECT Id, Name, cscfga__Parent_Configuration__c,
cscfga__Product_Definition__r.Name
FROM cscfga__Product_Configuration__c
WHERE Id = '<CONFIGURATION_ID>'
If cscfga__Parent_Configuration__c is null and the configuration should have a parent, this confirms the issue.
Step 3: Determine the Correct Parent Configuration
For standalone/root configurations:
- If this is intentionally a root-level configuration with no parent, verify the data model design
- Check if similar working configurations have parent references
For child configurations:
- Identify the parent configuration from the basket structure
- Query related configurations to find the appropriate parent:
SELECT Id, Name, cscfga__Parent_Configuration__c
FROM cscfga__Product_Configuration__c
WHERE cscfga__Product_Basket__c = '<BASKET_ID>'
ORDER BY CreatedDate
Step 4: Update the Parent Configuration Field
Once the correct parent is identified, update the field:
UPDATE cscfga__Product_Configuration__c
SET cscfga__Parent_Configuration__c = '<PARENT_CONFIG_ID>'
WHERE Id = '<CONFIGURATION_ID>'
Step 5: Verify Resolution
- Refresh the basket page
- Click the Deal Management button
- Confirm the page loads without errors
Additional Notes
- Data Model Review: If this issue occurs frequently, review your configuration creation process to ensure parent-child relationships are established correctly
- Custom Code: If using custom code to create Product Configurations, ensure
cscfga__Parent_Configuration__cis populated appropriately - Validation Rules: Consider adding validation rules to prevent configurations from being created without required parent references where applicable
- Alternative Scenario: If the configuration is intentionally a root configuration without a parent, the custom JavaScript code in the
onAfterInitialLoadhandler may need adjustment to handle null parent references gracefully
Priyanka Bhotika
Comments