cancel
Showing results for 
Search instead for 
Did you mean: 

Button Basics in Story Mode SAC

marammohd
Explorer

Hello -

I am seeking support with something extremely fundamental, but cannot find resources anywhere...

I recently added in a few buttons as widgets to the first page of a dashboard aka story I am developing.

How would I script the button to direct me to a different page of the story when it is clicked by the user?

Accepted Solutions (1)

Accepted Solutions (1)

N1kh1l
Active Contributor

maram.mohd

Just put the below script in on click of the button

Application.setActivePage('Page_1') // change the page name as per your requirement

Br.

Nikhil

FxGk
Participant
0 Kudos

You can also use the number of the page by putting

Application.setActivePage(1);

But is there a way to get the numeric value of the active Page?

If you use

Application.getActivePage();

you just get the key as a string.

N1kh1l
Active Contributor
0 Kudos

fx.gk

There is no API which return the Page numeric value as its just the numeric sequence of the page irrespective of name. I am not sure the use case where you would need the numeric of the page but if its a pressing need you can just create a widget with numeric id like P1 , P2 in each of these pages and then just use something like below

var pg =Page_1.getWidgets({type:WidgetType.TextArea});
console.log(pg[0]);

Output

Br.

Nikhil

FxGk
Participant

The idea was to set up two buttons (back and next) to jump to the previous or next page. For the purpose of reuse the buttons on other pages or stories i thought of something like

var activePage = Application.getActivePage() // here I need the numeric value

Application.setActivePage(activePage + 1) // next page
Application.setActivePage(activePage - 1) // previous page 

Felix

marammohd
Explorer
0 Kudos

worked like a charm, thank you.

Answers (1)

Answers (1)

vrajgopal
Explorer

Please refer to the below post. Although it talks about drop down instead of button, I think you can still leverage it for buttons.

https://blogs.sap.com/2023/11/23/start-your-scripting-journey-the-easy-way-with-sap-analytics-cloud-...