Trigger a Button or other field using JavaScript: .click()

It's possible to "click" a Button or certain other other controls using JavaScript. This can be used to chain actions together, enable further functionality, or automate some processes. This is done by using .click() on the field.

Controls that .click() can be used upon in Synergy and CallScripter 4.5:

  • Accordion - Start
  • Back Button
  • Button
  • Button - Tabs
  • Conditional Button
  • External Data Source
  • JavaScript - Button
  • Table
  • Toast Popup
  • Toast Remove
  • Web Frameset - Open
  • Web Frameset - Close
Controls that .click() can be used upon in Synergy:
  • Clear Data
  • Email
  • GoToPage
  • IFrame
  • Mail Merge
  • Outcome - Button
  • Outcome - List
  • SMS
  • Social Reply
Controls that .click() can be used upon in CallScripter 4.5:
  • Button - Component Link
  • Close Window
  • Database - Get
  • Lookup
  • Report Runner (all variants)
  • Toolbar Label - Add
  • Toolbar Label - Remove


Prior to being able to .click() a field, it must be passed through a function that returns the HTML object. Further details can be found here.
In Synergy, the field needs to be wrapped in a Script.Utils.GetCSObject() function call before it can have .click() used upon it.
Script.Utils.GetCSObject([My Button]).click()
In CallScripter 4.5, the field needs to be wrapped in a getCSObject() function call before it can have .click() used upon it. Note the differing capitalisation.
getCSObject([My Button]).click()


It is still possible to .click() fields while they are hidden. So hidden buttons can be placed on a script page that each lead to different pages, and then a visible JavaScript Button can be used to .click() them based on particular conditions to form a more advanced version of a Conditional Button.
In many cases (such as the External Data Source), when a field has .click() used on it it starts a separate process running in parallel to the main JavaScript thread. Upon the completion of this thread, often it will then invoke doCalculations() which causes all field values to be refreshed and any Calculate fields on the page to run again.
This also means that if .click() is used on a Button immediately after an External Data Source, or Script.Utils.Navigate() is used immediately after using .click() on an External Data Source, it is possible to leave the page prior to the External Data Source actually completing its triggered action. To avoid this issue, the suggested action is to only .click() the External Data Source, and then have the External Data Source use Update Links to trigger any follow-up actions when it has completed.
Use caution when .click() fields to not trigger them repeatedly. Some fields (like the Email control) will trigger doCalculations() upon completion and can be re-triggered by .click() and this can lead to a loop where thousands of actions are queued. Ideally, .click() should only be invoked from inside a "run once" or similarly controlled method.