From sap-sac-scripting
Guides debugging of SAC script errors with step-by-step analysis, common error patterns, and console logging techniques.
How 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 *...
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:
npx claudepluginhub andreafusar/https-github.com-secondsky-sap-skills --plugin sap-sac-scripting2plugins reuse this command
First indexed Jan 9, 2026
/sac-debugGuides debugging of SAC script errors with step-by-step analysis, common error patterns, and console logging techniques.
/widget-lintLints SAP Analytics Cloud custom widget code for performance issues, security risks, and best practice violations, outputting categorized results with severity scores and actionable recommendations.
/systematic-debuggingPerforms root-cause analysis on evaluation failures and implements fixes by invoking a dedicated debugging skill.
/debugTriggers a structured debugging workflow when encountering bugs, test failures, or unexpected behavior — before proposing any fixes.
/cap-troubleshooterDiagnoses common SAP CAP errors across syntax, deployment, database, auth, and performance categories with step-by-step solutions.
/fire-debugDebugs issues using a systematic scientific-method workflow with subagent isolation, persistent session state, skills library patterns, and past-reflection matching. Accepts an optional issue description and --diagnose-only or --verbose flags.