onScriptInit event always retriggered by fields ajax events in forms - why?

Scenario with a form app set as follows:

  • code in the onScriptInt event
  • code in an onchange ajax event bound to a field

Whenever the ajax event is triggered by the end user changing the value in the field, SC actually first executes the onScriptInit event and then the specific ajax event for the field.

@NetMake: is this by design? is there any reason to do it?

It can slow down the ajax execution and also have an unexpected behavior

3 Likes

Hi @robydago , does anyone ever answered this topic?
It cause very unexpected beahaviors …

Hi @Benito90,

no answer

1 Like

@NetMake @Scriptcase_Espanol Any info please ?

i never checked actually, but this behaviour, if true, could be very wrong ,
if you set up the initial values in the oninit , query database etc. performance killer as well.

update, just checked , indeed , onScriptInit is triggered. also when the dependent checklists are updated.

nevertheless, in case you want to log all ajax calls, you could log it in onscriptinit. so this onscriptinit can be useful if you are aware of it is triggered on every ajax call. in case you want your startup script run just once at the initial load, use onapplicationinit

I moved my onScriptInit code to onApplicationInit , and now it executes just once, as intended.