SAP Knowledge Base Article - Public

3290527 - OnSelect event is triggered multiple times


OnSelect event triggered multiple times unexpectedly.


SAC Application Designer

Reproducing the Issue

Use onselect() within a chart.


This is the designed behavior with the chart widget. If you click outside a chart widget, it will lose the datapoint selection. This behavior is inherited from the story mode.


The actual meaning of chart's "onSelect" event would be "selectionChange", but due to some historical and design reasons, it's still named "onSelect". This is root cause of the misunderstanding.


Add code to prevent the logic code from the second trigger . Below are some ideas on this check.

1) Check length

if(Chart_1.getSelections().length !== 0){
//your event code

There are other mechanisms that may also work 

2) Global Flag
set the flag 0 when opening the app the first time. Check flag at onselect beginning, exit if not 0. Set it to 1 at the end of the console update. Reset flag to 0 when user does refresh.

3) Selection comparison
store selection as var. Compare the previous selection type/id/description...etc to existing. exit if the same 


KBA , LOD-ANA-AD , Analytics Designer , Problem


SAP Analytics Cloud 1.0