• Solutions
  • Services
  • Sectors
  • Sharing
  • About Us

Enhance Your SAP Analytics Cloud Stories with Scripting

Discover how to elevate your dashboards with custom logic in SAP Analytics Cloud! In this video, Kris takes you through the first steps of scripting to unlock powerful, tailored functionalities in your stories.

Key Highlights:

  • Add buttons with onClick actions

  • Show/hide panels and popups

  • Switch measures and manage multiple objects

Hereby the scripts for the four shown topics in the McCoy TV: 

Show and Hide Panels 

Make sure this is on the onClick-sript of the button where you want to apply this:

// If the filterpanel is visible: hide the filterpanel
if (Demo_Filter.isVisible() === true) {
  Demo_Filter.setVisible(false);
  Demo_Body.getLayout().setLeft(15);
  Demo_Numeric.getLayout().setLeft(15);
}
// else if the filterpanel is invisible: show the filterpanel
else if (Demo_Filter.isVisible() === false) {
  Demo_Filter.setVisible(true);
  Demo_Body.getLayout().setLeft(250);
  Demo_Numeric.getLayout().setLeft(250);
} 

Retrieve a Popup

Make sure you can close and open the popup.

  • To open the popup, use [Popup-name].open();

  • To close the popup, use [Popup-name].close();

 

CY <--> YTD Switch

if (Switch_1.isOn() === false) {
  // Notification on the new setting
  Application.showMessage(ApplicationMessageType.Success, "You've selected YTD");
              
  // Remove CY Measures
  Chart_1.removeMember(Feed.ValueAxis, "20382204-0635-4508-3663-224197897322"); //Profit CY
  Chart_1.removeMember(Feed.ValueAxis, "22011059-3187-4902-3986-254867627317"); //Sales
  Chart_1.removeMember(Feed.ValueAxis, "34764521-4237-4475-3692-222410153142"); //COGS CY
              
  // Set YTD Measures
  Chart_1.addMember(Feed.ValueAxis, "37554691-7515-4533-3635-730697853521"); //Profit YTD
  Chart_1.addMember(Feed.ValueAxis, "42482451-2393-4233-3816-388409155026"); //Sales YTD
  Chart_1.addMember(Feed.ValueAxis, "51948958-7154-4722-3534-181755600934"); //COGS YTD
} else if (Switch_1.isOn() === true){

  // Notification on the new setting
  Application.showMessage(ApplicationMessageType.Success, "You've selected CY");

  // Remove YTD Measures
  Chart_1.removeMember(Feed.ValueAxis,  "37554691-7515-4533-3635-730697853521"); //Profit YTD
  Chart_1.removeMember(Feed.ValueAxis, "42482451-2393-4233-3816-388409155026"); //Sales YTD
  Chart_1.removeMember(Feed.ValueAxis, "51948958-7154-4722-3534-181755600934"); //COGS YTD
                                                                                     
  // Set CY Measures
  Chart_1.addMember(Feed.ValueAxis,"20382204-0635-4508-3663-224197897322"); //Profit CY
  Chart_1.addMember(Feed.ValueAxis, "22011059-3187-4902-3986-254867627317"); //Sales CY
  Chart_1.addMember(Feed.ValueAxis, "34764521-4237-4475-3692-222410153142"); //COGS CY
}

Measure switch

if (Switch_2.isOn() === false) {
  // Notification on the new setting
  Application.showMessage(ApplicationMessageType.Success, "You've selected Line");
  
  // Hide Charts
  Profit_Num.setVisible(false);
  Units_Num.setVisible(false);
  Gross_Num.setVisible(false);
  Sales_Num.setVisible(false);
  
  // Show Lines
  Profit_Line.setVisible(true);
  Units_Line.setVisible(true);
  Gross_Line.setVisible(true);
  Sales_Line.setVisible(true);
    
} else if (Switch_2.isOn() === true) {

  // Notification on the new setting
  Application.showMessage(ApplicationMessageType.Success, "You've selected Chart");
  
  // Hide Lines
  Profit_Line.setVisible(false);
  Units_Line.setVisible(false);
  Gross_Line.setVisible(false);
  Sales_Line.setVisible(false);
  
  // Show Charts
  Profit_Num.setVisible(true);
  Units_Num.setVisible(true);
  Gross_Num.setVisible(true);
  Sales_Num.setVisible(true);
}

Are you a Friend of McCoy?

As an innovation partner, we want to continue inspiring you. That's why we gladly share our most relevant content, events, webinars, and other valuable updates with you.