Problem
After configuring products in the Solution Console and saving the configuration, the basket remains in a "dirty" state, indicating unsaved changes even though the save operation appeared to complete successfully. This manifests as:
- The "Save" button remains enabled or highlighted
- A warning message appears when trying to navigate away: "You have unsaved changes"
- The basket shows indicators of pending changes
- Subsequent operations fail because the system detects unsaved modifications
This prevents users from proceeding with order activation or other downstream processes, as the system believes there are uncommitted changes.
Root Cause
Custom Apex code in an afterSave hook or trigger is modifying product configuration or basket-related records after the initial save operation completes. These post-save modifications update the records in the database, but the Solution Console's client-side state is not notified of these changes.
The Solution Console tracks the "dirty" state by comparing the client-side data model with the last known saved state. When custom code modifies records after the save completes:
1. The client-side model reflects the pre-modification state
2. The database contains the post-modification state
3. The Solution Console detects a mismatch and marks the basket as "dirty"
Common scenarios include:
- Custom triggers on cscfga__Product_Configuration__c that update fields after insert/update
- Workflow rules or Process Builder flows that modify configurations post-save
- Custom afterSave hooks in CloudSense plugins that update related records
- Asynchronous processes (Future methods, Queueables) that modify configurations shortly after save
Resolution
Step 1: Identify Custom Post-Save Logic
- Navigate to Setup > Apex Triggers
- Search for triggers on the following objects:
cscfga__Product_Configuration__ccscfga__Basket__ccsord__Solution__c-
cscfga__Attribute_Value__c -
Review each trigger for
after insertandafter updatelogic -
Note any triggers that modify records after the initial save
-
Navigate to Setup > Process Builder
- Search for processes that run on the above objects
-
Review for any "Update Records" actions that occur after the initial save
-
Navigate to Setup > Flows
- Search for flows triggered by record changes on the above objects
- Review for any post-save update actions
Step 2: Review Custom Plugin Code
If your org uses custom CloudSense plugins:
- Navigate to Setup > Static Resources
- Locate custom plugin JavaScript files
- Search for
afterSavehooks or event handlers - Review the code for any logic that modifies records after save
Step 3: Modify Custom Code to Prevent Dirty State
Apply one of the following fixes depending on the custom code type:
Fix A: Move Logic to Before Save
If the custom logic can be executed before the save completes:
- Move the logic from
after insert/updatetobefore insert/updatein Apex triggers - This ensures modifications are included in the initial save transaction
- The Solution Console will receive the final state in the save response
Fix B: Suppress Client-Side Dirty State Check
If the post-save modifications are necessary and cannot be moved:
- Add a custom setting or flag to indicate that post-save modifications are expected
- Update the Solution Console configuration to suppress the dirty state check for these specific scenarios
- This requires coordination with CloudSense support or engineering
Fix C: Refresh the Basket After Save
If the post-save modifications are infrequent:
- After the save completes, programmatically refresh the basket in the Solution Console
-
Add custom JavaScript to the Solution Console page:
javascript // After save completes CS.SM.refreshSolutionConsole(); -
This forces the client-side model to reload from the database, picking up the post-save modifications
Fix D: Use Asynchronous Notifications
If the post-save modifications are asynchronous:
- Implement a callback mechanism that notifies the Solution Console when modifications complete
- Use Salesforce Platform Events or custom events to signal completion
- Update the Solution Console to listen for these events and refresh the basket
Step 4: Test the Fix
- Clear your browser cache
- Open the Solution Console
- Configure a product and save the configuration
- Verify the basket no longer shows a "dirty" state after save
- Confirm the "Save" button is disabled or no longer highlighted
- Verify no warning appears when navigating away
- Test order activation to ensure it proceeds without errors
Step 5: Deploy to Production
- If testing was done in a sandbox, deploy the fixed code to production
- Test with a representative user
- Monitor for any recurring dirty state issues
Prevention
For Salesforce Developers
- Before Save Logic: Prefer
before insert/updatetriggers overafter insert/updatefor modifications that should be part of the initial save - Synchronous vs Asynchronous: Understand the impact of asynchronous modifications on client-side state management
- Testing: Test custom code with the Solution Console to verify the dirty state is not triggered
- Documentation: Document all post-save modifications and their impact on CloudSense components
For Salesforce Administrators
- Code Review: Review all custom triggers, workflows, and flows on CloudSense objects for post-save modifications
- Change Management: Require testing with CloudSense components before deploying custom code to production
- Monitoring: Monitor for user reports of persistent "unsaved changes" warnings
For Implementation Teams
- Best Practices: Establish coding standards that minimize post-save modifications on CloudSense objects
- CloudSense Compatibility: Test all custom code for compatibility with CloudSense client-side state management
- Training: Train developers on CloudSense architecture and the implications of post-save modifications
Related Information
- Affected Components: CloudSense Solution Console (Angular and React versions)
- Affected Objects:
cscfga__Product_Configuration__c,cscfga__Basket__c,csord__Solution__c,cscfga__Attribute_Value__c - Related Concepts: Client-side state management, dirty state tracking, Apex trigger execution order
- Trigger Types:
before insert,before update,after insert,after update - Related Processes: Product configuration save, basket management, solution console state synchronization
Priyanka Bhotika
Comments