Replace CSV export with Copy SOQL to Clipboard#14
Replace CSV export with Copy SOQL to Clipboard#14jillian-k wants to merge 4 commits intobhanudas:mainfrom
Conversation
- Correct Child_Filter_Field__c from dot-notation to bare field API name (UJET__Fail_Reason__c) - Remove literal quotes from Child_Filter_Value__c (eu_abandoned) - Add Abandoned_Calls custom metadata record to source control with corrected values - Update inlineHelpText on Child_Filter_Field__c, Child_Filter_Value__c, Owner_Name_Like__c, and Last_Modified_By_Name_Like__c to prevent misconfiguration - Add closinator-child-object-debug debug doc with full root cause analysis and fix summary Made-with: Cursor
New LWC (util_closer_RuleViewer) displays active Case Status Auto-Closer rules in a collapsible accordion layout so users can see what rules and criteria are configured without navigating to Setup. Includes new Apex controller, test class with 100% coverage, and feature documentation. Made-with: Cursor
The CSV download exceeded the 6MB Apex heap limit for batches with more than ~6,000 case logs. Replace with a button that builds the SOQL query server-side and copies it to the clipboard, shown in a sticky toast so the user can run it in Dev Console or Workbench. Made-with: Cursor
navigator.clipboard is not available in Locker Service context.
Use textarea + execCommand('copy') fallback instead.
Made-with: Cursor
Greptile SummaryThis PR replaces the CSV export (which hit Apex heap limits at ~6,000+ records) with a "Copy SOQL to Clipboard" button that calls a new
Confidence Score: 4/5Safe to merge after fixing the clipboard failure path — the Apex side is solid but the LWC shows a success toast even when the copy silently fails. One P1 finding: document.execCommand('copy') return value is ignored, leading to a misleading success toast on clipboard failure. All other changes (Apex controller, tests, HTML) are clean. Score is 4 rather than 5 because of this present UX defect on the changed path. force-app/main/default/lwc/util_closer_LogViewer/util_closer_LogViewer.js — copyToClipboard and handleCopySoql need to handle a false return from execCommand. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant LWC as util_closer_LogViewer.js
participant Apex as LogViewerController.cls
participant CB as Clipboard (execCommand)
U->>LWC: Click "Copy SOQL to Clipboard"
LWC->>Apex: getCaseLogExportQuery(batchLogId, filterJson)
Apex-->>LWC: SOQL string
LWC->>CB: document.execCommand('copy') via hidden textarea
CB-->>LWC: true / false (⚠️ return value ignored)
LWC->>U: ShowToastEvent — "SOQL Copied" (always, even on failure)
|
| document.execCommand('copy'); | ||
| document.body.removeChild(textarea); |
There was a problem hiding this comment.
Silent clipboard failure shows false success toast
document.execCommand('copy') returns false when the copy fails (e.g., the element wasn't focused, the browser blocks it, or the API is not supported). The current code ignores this return value, so handleCopySoql always calls showToast('SOQL Copied to Clipboard', ...) even when nothing was actually written to the clipboard — the user gets a success message for a failed operation.
| document.execCommand('copy'); | |
| document.body.removeChild(textarea); | |
| const success = document.execCommand('copy'); | |
| document.body.removeChild(textarea); | |
| return success; |
Then in handleCopySoql, check the result:
const copied = this.copyToClipboard(soql);
if (copied) {
this.showToast('SOQL Copied to Clipboard', soql, 'success', 'sticky');
} else {
this.showError('Clipboard Copy Failed', { message: 'Could not copy SOQL. Please copy it manually.' });
}Why did the programmer break up with the clipboard? Because it kept taking things without asking! 📋
Prompt To Fix With AI
This is a comment left during a code review.
Path: force-app/main/default/lwc/util_closer_LogViewer/util_closer_LogViewer.js
Line: 659-660
Comment:
**Silent clipboard failure shows false success toast**
`document.execCommand('copy')` returns `false` when the copy fails (e.g., the element wasn't focused, the browser blocks it, or the API is not supported). The current code ignores this return value, so `handleCopySoql` always calls `showToast('SOQL Copied to Clipboard', ...)` even when nothing was actually written to the clipboard — the user gets a success message for a failed operation.
```suggestion
const success = document.execCommand('copy');
document.body.removeChild(textarea);
return success;
```
Then in `handleCopySoql`, check the result:
```js
const copied = this.copyToClipboard(soql);
if (copied) {
this.showToast('SOQL Copied to Clipboard', soql, 'success', 'sticky');
} else {
this.showError('Clipboard Copy Failed', { message: 'Could not copy SOQL. Please copy it manually.' });
}
```
Why did the programmer break up with the clipboard? Because it kept taking things without asking! 📋
How can I resolve this? If you propose a fix, please make it concise.
Summary
document.execCommand('copy')fallback sincenavigator.clipboardis unavailable in Lightning Locker ServiceChanges
util_closer_LogViewerController.clsexportCaseLogsAsCsvwithgetCaseLogExportQuery-- returns SOQL string without executing itutil_closer_LogViewerController_Test.clsutil_closer_LogViewer.jsutil_closer_LogViewer.htmlutility:copy_to_clipboard, updated tooltipdocs/closinator-soql-toast/soql-toast-feature.mdTest plan
Made with Cursor