# Solution

## Overview

The `Servoy solution` represents a `project` that encapsulates both user interface and business logic. It supports modular design by allowing integration with other solutions defined as modules, improving organizational flexibility. Key properties include `comment` for programmer notes, `firstForm` to define the initial form upon deployment, and `modulesNames` listing the modules added to the solution. Authentication requirements are managed with `mustAuthenticate`, while `solutionType` specifies the type of solution, such as "Normal", "Module", "NG Client", or "Service". Other attributes like `styleSheet`, `titleText`, and `version` provide customization options and semantic versioning support.

Notable events include `onOpen`, triggered when the solution starts, and `onClose`, which allows conditional termination. The `onAutoSaveFailed` event captures validation or save failures during automatic saving. Additional functionality is available through events like `onDataBroadcast` for handling data updates and `onError` to manage runtime exceptions.

The solution provides flexible integration with login forms, internationalization, and custom styling, offering extensive configurability for various application requirements.

## Properties Summarized

| Type                                                                           | Name                                    | Summary                                                                                                                                                                                                                                                                                 |
| ------------------------------------------------------------------------------ | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [comment](#comment)                     | Additional design time information, such as programmer notes about this model object's purpose.                                                                                                                                                                                         |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)   | [eventTypes](#eventtypes)               | These are the event types of the solution that can be added/fired/removed from eventsManager object.                                                                                                                                                                                    |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [firstForm](#firstform)                 | The first form that loads when a solution is deployed.                                                                                                                                                                                                                                  |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [i18nDataSource](#i18ndatasource)       | The i18n database server connection and database table that stores the i18n keys for a solution.                                                                                                                                                                                        |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [loginForm](#loginform)                 | The name of the login form that loads when a solution is deployed.                                                                                                                                                                                                                      |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [loginSolutionName](#loginsolutionname) | Get the first module that is also a login solution.                                                                                                                                                                                                                                     |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [modulesNames](#modulesnames)           | The list of modules that have been added to a solution.                                                                                                                                                                                                                                 |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) | [mustAuthenticate](#mustauthenticate)   | Flag that tells if authentication is needed in order to access the solution.                                                                                                                                                                                                            |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)   | [solutionType](#solutiontype)           | The type of a solution; can be "Normal" (non-module), "Module", "Web client only (deprecated)", "Smart client only (deprecated)", "Login", "Authenticator", "Pre-import hook module", "Post-import hook module", "Mobile", "Mobile shared module", "NG Client", "NG Module", "Service". |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [styleSheet](#stylesheet)               | The custom CSS used by the solution (a MEDIA lib entry).                                                                                                                                                                                                                                |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)   | [textOrientation](#textorientation)     | The direction that text is displayed.                                                                                                                                                                                                                                                   |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [titleText](#titletext)                 | The menu bar title of a solution.                                                                                                                                                                                                                                                       |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [version](#version)                     | This is the version of the solution, this can be any kind of string but try to follow "Semantic Versioning".                                                                                                                                                                            |

## Events Summarized

| Type                                                                           | Name                                                                                              | Summary                                                                                                                   |
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| void                                                                           | [onAutoSaveFailed(recordMarkers)](#onautosavefailed-recordmarkers)                                | The method that is executed when autosave results in validation or save failures.                                         |
| void                                                                           | [onBeforeLogin(queryParams)](#onbeforelogin-queryparams)                                          | The method that is to onOpen just that it executes before the login on solutions with a login form (not login soliution). |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) | [onClose(force)](#onclose-force)                                                                  | The method that is executed when a solution closes.                                                                       |
| void                                                                           | [onDataBroadcast(dataSource, action, pks, cached)](#ondatabroadcast-datasource-action-pks-cached) | Method that is executed when data broadcast occurs.                                                                       |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) | [onError(ex)](#onerror-ex)                                                                        | The method that is executed when a solution opens and an error occurs.                                                    |
| void                                                                           | [onOpen(arg, queryParams)](#onopen-arg-queryparams)                                               | The method that is executed when a solution opens.                                                                        |

## Properties Detailed

### comment

Additional design time information, such as programmer notes about this model object's purpose.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

### eventTypes

These are the event types of the solution that can be added/fired/removed from eventsManager object.\
These event types are added on top of default form events.\
They can be access through EventType.name property when used to fire or listen to.

**Type**\
[Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)

### firstForm

The first form that loads when a solution is deployed.

NOTE: If the Login form is specified, then the firstForm is the first form that will load next after the loginForm.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

### i18nDataSource

The i18n database server connection and database table that stores the i18n keys for a solution.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

### loginForm

The name of the login form that loads when a solution is deployed.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

### loginSolutionName

Get the first module that is also a login solution.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

### modulesNames

The list of modules that have been added to a solution.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

### mustAuthenticate

Flag that tells if authentication is needed in order to access the solution.\
If checked, authentication is required, and either a provided loginSolution or otherwise the default Servoy login mechanism will be used.\
If default Servoy login mechanism is used, the "servoy.webclient.basic.authentication" setting on the Admin Page can be used to enable the use of the standard browser basic authentication.

**Type**\
[Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

### solutionType

The type of a solution; can be "Normal" (non-module), "Module", "Web client only (deprecated)", "Smart client only (deprecated)", "Login", "Authenticator", "Pre-import hook module", "Post-import hook module", "Mobile", "Mobile shared module", "NG Client", "NG Module", "Service".

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

### styleSheet

The custom CSS used by the solution (a MEDIA lib entry). It can reference other media resources (even additional .css through relative '@import' statements).\
For NGClient - this CSS will be available directly in the browser.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

### textOrientation

The direction that text is displayed.

Options include:\
DEFAULT\
left to right\
right to left\
locale specific

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

### titleText

The menu bar title of a solution.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

### version

This is the version of the solution, this can be any kind of string but try to follow "Semantic Versioning".\
This version is important when you are making modules that are distributed by the Servoy Package Manager.\
Then this version is used to know what the developer has installed. This version should be in sync then with the webpackage.json file.

**Type**\
[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

## Events Detailed

### onAutoSaveFailed(recordMarkers)

The method that is executed when autosave results in validation or save failures.\
This is not called for save or validate calls that are triggered from javascript itself (databaseManager.saveData()), only when Servoy tries an auto save\
because of some event like user clicking on the form itself or foundset selection change.

**Parameters**

* [JSRecordMarkers\[\]](https://github.com/Servoy/gitbook/blob/master/reference/servoycore/object-model/solution/jsrecordmarkers\[].md) **recordMarkers** an array of all the record markers that failed to validate or save.

**Returns:** void

### onBeforeLogin(queryParams)

The method that is to onOpen just that it executes before the login on solutions with a login form (not login soliution). The default is -none-.

**Parameters**

* [Object\<Array\<String>|String>](https://github.com/Servoy/gitbook/blob/master/reference/servoycore/object-model/solution/object%3Carray%3Cstring%3E|string%3E.md) **queryParams** all query parameters of the deeplink url with which the Client was started, key>string if there was one value else key>Array\<String>

**Returns:** void

### onClose(force)

The method that is executed when a solution closes. The default is -none-.

**Parameters**

* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **force** if false then solution close can be stopped by returning false

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

### onDataBroadcast(dataSource, action, pks, cached)

Method that is executed when data broadcast occurs. The default is -none-.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **dataSource** table data source
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **action** see SQL\_ACTION\_TYPES constants
* [JSDataSet](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/jsdataset) **pks** affected primary keys
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **cached** data was cached

**Returns:** void

### onError(ex)

The method that is executed when a solution opens and an error occurs. The default is -none.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **ex** exception to handle

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

### onOpen(arg, queryParams)

The method that is executed when a solution opens. The default is -none-.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **arg** startup argument part of the deeplink url with which the Client was started
* [Object\<Array\<String>|String>](https://github.com/Servoy/gitbook/blob/master/reference/servoycore/object-model/solution/object%3Carray%3Cstring%3E|string%3E.md) **queryParams** all query parameters of the deeplink url with which the Client was started, key>string if there was one value else key>Array\<String>

**Returns:** void

***
