Switch to: V12V11V10V9V8V7V6V5

Form Editor - Scripts

Scripts written in JavaScript language are extensively used in the forms to provide internal logic.

There are three kinds of scripts used with forms:

  • Slots โ€“ scripts intended to respond to certain events of the form or in the controls, they have a separate group in the properties of the object with slots:

  • User-defined methods of the form.
  • Scripts objects โ€“ independent named JavaScript code saved in the project tree. Script object can be imported into slots and methods, a form can be imported into such a script.

Form Object

To access the form object from within the script the keyword this is used, for example:


All controls of the form are accessible as the properties of the form:

name = this.cboName.currentText;

It is possible to define custom properties for the form objects, they are shared between the form scripts:

this.cboName.myProp = "prop1";

Import Forms

It is possible to execute one form from another, get data from it:

import '/UserDetails' as dlg;
if( dlg.exec() )
    this.cboUser.currentIndex = this.cboUser.ids.indexOf( dlg.getUserAddedId() );

Import Scripts

It is possible to use script objects in forms.

For example, utility functions used in multiple forms can be imported into a button slot:

// tbEmail: QToolButton - clicked
import '/Scripts/base64'
const buf = this.report.printToBuffer( REPORT_PRINT_TYPE.TO_PDF );
const b64 = base64ArrayBuffer( buf );

Startup Script

Script objects can be used to define the startup script โ€“ script which is executed at the project opening.

For example, this script can automatically show a form when the user opens a project, to work with forms like with the standalone applications.