# JSRecordMarkers

## Overview

The `JSRecordMarkers` scripting wrapper represents the validation state of a record and provides tools for managing and reporting validation failures. It tracks whether errors or warnings occurred during operations like saving, updating, or deleting records. ## Functionality

The `hasErrors` property indicates whether the validation process encountered blocking errors or only warnings. Other properties, such as `onBeforeDeleteFailed`, `onBeforeInsertFailed`, and `onBeforeUpdateFailed`, signal failures in specific lifecycle operations. The `record` property links the markers to the associated record, providing a direct reference to the affected data.

The wrapper supports retrieving detailed validation results. The `getMarkers` method returns all reported validation problems, while its variant with a `level` parameter filters issues by severity. `getGenericExceptions` lists any generic exceptions that occurred during operations. The `report` method allows developers to add custom markers programmatically, with support for internationalized messages, logging levels, and optional metadata.

These features make JSRecordMarkers an essential tool for robust validation workflows in Servoy applications, ensuring fine-grained error handling and reporting.

You may also refer to the [Record Markers - View Record](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/viewrecord#recordmarkers) documentation.

## Properties Summarized

| Type                                                                                       | Name                                          | Summary                                           |
| ------------------------------------------------------------------------------------------ | --------------------------------------------- | ------------------------------------------------- |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)             | [hasErrors](#haserrors)                       |                                                   |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)             | [onBeforeDeleteFailed](#onbeforedeletefailed) |                                                   |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)             | [onBeforeInsertFailed](#onbeforeinsertfailed) |                                                   |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)             | [onBeforeUpdateFailed](#onbeforeupdatefailed) |                                                   |
| [JSRecord](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/jsrecord) | [record](#record)                             | The record for which this JSRecordMarkers is for. |

## Methods Summarized

| Type                                                                       | Name                                                                                                                                     | Summary                                                                                                                                                                                                                                                                                                                                        |
| -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) | [getGenericExceptions()](#getgenericexceptions)                                                                                          | Returns a list of all the generic exceptions that did happen when the various methods where called.                                                                                                                                                                                                                                            |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) | [getMarkers()](#getmarkers)                                                                                                              | This returns all the problems found when validation the record.                                                                                                                                                                                                                                                                                |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) | [getMarkers(level)](#getmarkers-level)                                                                                                   | This returns the problems found when validation the record filtered by the given level                                                                                                                                                                                                                                                         |
| void                                                                       | [report(message)](#report-message)                                                                                                       | Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables. |
| void                                                                       | [report(message, dataprovider)](#report-message-dataprovider)                                                                            | Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables. |
| void                                                                       | [report(message, dataprovider, level)](#report-message-dataprovider-level)                                                               | Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables. |
| void                                                                       | [report(message, dataprovider, level, customObject)](#report-message-dataprovider-level-customobject)                                    | Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables. |
| void                                                                       | [report(message, dataprovider, level, customObject, messageKeyParams)](#report-message-dataprovider-level-customobject-messagekeyparams) | Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables. |

## Properties Detailed

### hasErrors

**Type**\
[Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) If this validation object has errors or only warnings which don't block the save.

### onBeforeDeleteFailed

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

### onBeforeInsertFailed

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

### onBeforeUpdateFailed

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

### record

The record for which this JSRecordMarkers is for.

**Type**\
[JSRecord](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/jsrecord) the record

## Methods Detailed

### getGenericExceptions()

Returns a list of all the generic exceptions that did happen when the various methods where called.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the genericExceptions

### getMarkers()

This returns all the problems found when validation the record.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) all the problems that where reported by a report() call.

### getMarkers(level)

This returns the problems found when validation the record filtered by the given level

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **level** a level of a marker that should be returned.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) all the problems that where reported by a report() call.

### report(message)

Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **message** The message (can be i18n)

**Returns:** void

### report(message, dataprovider)

Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **message** The message (can be i18n)
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **dataprovider** The dataprovider for which this marker is for.

**Returns:** void

### report(message, dataprovider, level)

Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **message** The message (can be i18n)
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **dataprovider** The dataprovider for which this marker is for.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **level** The LOGGINGLEVEL like ERROR or WARNING

**Returns:** void

### report(message, dataprovider, level, customObject)

Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **message** The message (can be i18n)
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **dataprovider** The dataprovider for which this marker is for.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **level** The LOGGINGLEVEL like ERROR or WARNING
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **customObject** A custom object is default the customObject of the validate() call.

**Returns:** void

### report(message, dataprovider, level, customObject, messageKeyParams)

Create a new JSMarker by reporting a message, this message can be an i18n key (should then start with 'i18n') Optionally you can give a dataprovider for which this marker is reported, a LOGGINGLEVEL for this marker, some custom javascript object for later use and a array of message keys if the message was an i18n key with variables.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **message** The message (can be i18n)
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **dataprovider** The dataprovider for which this marker is for.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **level** The LOGGINGLEVEL like ERROR or WARNING
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **customObject** A custom object is default the customObject of the validate() call.
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **messageKeyParams** Some variables if he message is an i18n key that has place holders.

**Returns:** void

***
