Skip to content

Global Functions

  • unrequire(moduleName: string)
    Unloads or removes a previously loaded module from the cache.

  • alert(text: string)
    Displays an alert dialog with a message to the user.

  • confirm(text: string): boolean
    Displays a confirmation dialog with "OK" and "Cancel" buttons. Returns true if the user presses "OK" and false if "Cancel" is pressed.
    Returns true if the user confirms, false if they cancel, or undefined if canceled.

  • prompt(text: string, defaultInput: string): string
    Prompts the user for input with a text field, and returns the entered value as a string.

    • text: The prompt message shown to the user.
    • defaultInput: The default input value displayed in the input field.
    • Returns string value entered by the user, or undefined if canceled.
  • localize or i18n or L(literals: Array, ...values: Array): string
    Returns a localized string, useful for internationalization (i18n). It replaces placeholders in the literals with values provided.

  • debugBreak()
    Pauses the execution of the script at the point where the function is called, useful for debugging purposes.

  • executeSQL(storages: storages[], sql: string, ...params: Parameter[]): Records
    Executes a SQL query on the given one or more storages and returns the resulting records.

    • storages: An array of storages against which the query will be executed.
    • sql: The SQL query string.
    • params: Optional parameters to pass to the SQL query.
    • Returns: Records containing the result of the query.

    It is not advised to use this method, unless it’s necessary. Specifying sql in this method will be database specific and cannot be used on starages of different database kinds. We suggest database querying using data class names like:

    var contracts = Contract.
                      where(fieldName, WhereOperator.Equal, value).
                      select();
    

  • executeSQLProcedure(storages: storages[], proc: string, ...params: Parameter[]): Records
    Executes a stored procedure in the specified storages and returns the resulting records.

    • storages: An array of storages where the procedure will be executed.
    • proc: The name of the stored procedure.
    • params: Optional parameters to pass to the procedure.
    • Returns: Records containing the result of the procedure execution.
  • restartServer()
    Restarts the server. Typically used for applying configuration changes or fixing server-related issues.

  • sendMessage(msg: string, user?: string, computer?: string)
    Sends a message to a specified user or computer. If no user or computer is specified, it sends the message to all users or computers. When a message is sent, it triggers a response in the active application through the StartApp.onServerMessage(msg) callback.

    • msg: The message to send.
    • user: (Optional) The target user or group to receive the message. If not provided, the message is broadcasted to all users.
    • computer: (Optional) The target computer to receive the message. If not provided, the message is broadcasted to all computers.