Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Every listener that you create will follow this exact same structure.  The only changes that are required are the <Service ID> and the code that you want to execute when the service completes.
When a form is loaded one of the things that we do is look for all the listeners that may have been setup so you are free to place them where you like.  There are multiple places where you can put this listener but there are positives and negatives of each.  I will share my experience and you can decide which works best for you.  


Application OnStart

  • The form keyword does not exist at this level, therefore you have to explicitly retrieve the form for which you want to reference:

...

Code Block
languagejs
if(form !== null)
{
//place listener code
}


Form onLoad

  • The form onLoad is only called when that form is loaded, so you won't have to worry about checking to see if the form exists which simplifies the code you have to write.
  • The form object exists, which also simplifies the code you have to write.


In an Item

  • The form key word exists and the listener will only get loaded within the scope of this form and item.
  • The negative is that you have to remember to disconnect the event otherwise a new listener will get added everytime the event is triggered throughout the form's lifecycle.  The call changes slightly (note the new variable hdl and the disconnectEvent at the end):

...