Help us improve
Share bugs, ideas, or general feedback.
From sap-sac-scripting
Guides debugging of SAC script issues via info gathering, common error analysis (e.g., undefined functions, null checks), code fixes, and console logging tips. Optional error arg.
npx claudepluginhub andreafusar/https-github.com-secondsky-sap-skills --plugin sap-sac-scriptingHow this command is triggered — by the user, by Claude, or both
Slash command
/sap-sac-scripting:sac-debugThe summary Claude sees in its command listing — used to decide when to auto-load this command
Provide guided SAC script debugging assistance. ## Debugging Workflow ### Step 1: Gather Information Ask the user for: 1. **Error message** (if any) - exact text from console or SAC 2. **Script location** - which event handler (onSelect, onClick, onInitialization)? 3. **Widget types involved** - Chart, Table, Button, Dropdown? 4. **SAC environment** - Analytics Designer or Optimized Story Experience? 5. **What should happen** vs **what actually happens** ### Step 2: Common Error Analysis #### "undefined is not a function" **Cause**: Calling a method that doesn't exist on the object *...
/sac-debugGuides debugging of SAC script issues via info gathering, common error analysis (e.g., undefined functions, null checks), code fixes, and console logging tips. Optional error arg.
/widget-lintLints SAP Analytics Cloud custom widget code for performance issues, security concerns, best practices violations, and SAC integration problems, with severity scores and recommendations.
/fire-debugDebugs issues systematically with scientific method, subagent isolation, persistent sessions, skills library integration, and live docs lookup.
/investigateInvestigates bugs via structured root cause analysis: scopes to module, collects evidence, forms hypotheses, implements evidence-based fixes.
/debugInvokes oac:debugger skill to diagnose bugs, test failures, or unexpected behavior exactly as specified, before any fix proposals.
Share bugs, ideas, or general feedback.
Provide guided SAC script debugging assistance.
Ask the user for:
Cause: Calling a method that doesn't exist on the object
Check:
// Wrong: Method name typo or doesn't exist
Chart_1.getDataSoruce(); // Typo!
// Correct:
Chart_1.getDataSource();
Resolution:
Cause: Object is null/undefined when accessing property
Check:
// Wrong: selections might be empty
var value = Chart_1.getSelections()[0]["Location"];
// Correct: Check array length first
var selections = Chart_1.getSelections();
if (selections.length > 0) {
var value = selections[0]["Location"];
}
Resolution:
Cause: Trying to iterate over non-array
Check:
// Wrong: getSelections() might return null
for (var sel of Chart_1.getSelections()) { }
// Correct: Check for array
var selections = Chart_1.getSelections() || [];
for (var i = 0; i < selections.length; i++) { }
Cause: Dimension name doesn't match model exactly
Check:
// Wrong: Case mismatch or wrong name
ds.setDimensionFilter("location", "US"); // lowercase!
// Correct: Use exact dimension name from model
ds.setDimensionFilter("Location", "US"); // Match model case
Resolution:
// Add at script start
console.log("=== Script started ===");
// Log variables
console.log("Widget:", typeof Chart_1, Chart_1);
console.log("DataSource:", Chart_1.getDataSource());
console.log("Selections:", JSON.stringify(Chart_1.getSelections()));
// Log before operations
console.log("Applying filter:", dimensionName, filterValue);
sandbox.worker.main.*.js)// Check widget exists
if (typeof Chart_1 !== "undefined" && Chart_1 !== null) {
var ds = Chart_1.getDataSource();
if (ds !== null) {
// Safe to proceed
ds.setDimensionFilter("Location", "US");
} else {
console.error("Chart_1 has no data source assigned");
}
} else {
console.error("Chart_1 widget not found");
}
Widget Issues:
Data Source Issues:
API Issues:
Selection Issues:
// Test 1: Widget exists
console.log("Test 1 - Widget:", Chart_1);
// Test 2: Data source
console.log("Test 2 - DS:", Chart_1.getDataSource());
// Test 3: Get data
console.log("Test 3 - ResultSet:", Chart_1.getDataSource().getResultSet());
// Test 4: Selections
console.log("Test 4 - Selections:", Chart_1.getSelections());
// Add to event handler to confirm it fires
console.log("EVENT FIRED: onSelect at " + new Date().toISOString());
| Error | Likely Cause | Fix |
|---|---|---|
| undefined is not a function | Wrong method name | Check API docs |
| Cannot read property X of undefined | Null object access | Add null checks |
| X is not iterable | Non-array iteration | Verify array type |
| No error but no effect | Wrong dimension name | Check model schema |
| Script doesn't run | Event not connected | Check widget events |
Based on the provided error information, analyze the issue and provide: