# controller

## Overview

The controller represents a runtime form instance (`FormController`) and provides methods for manipulating forms programmatically.

It includes properties like `enabled`, `readOnly`, and `view` to control form behavior and appearance, and a variety of methods to manage data, set focus, and control the form’s user interface dynamically.

Functions like `find()` and `search()` enable advanced data querying capabilities.

All javascript calls must be delegated to the FormController

## Properties Summarized

| Type                                                       | Name                  | Summary                                                                                                                                                                           |
| ---------------------------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) | [enabled](#enabled)   | Gets or sets the enabled state of a form; also known as "grayed-out".                                                                                                             |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) | [readOnly](#readonly) | Gets or sets the read-only state of a form; also known as "editable" Note: The field(s) in a form set as read-only can be selected and the field data can be copied to clipboard. |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)   | [view](#view)         | Get/Set the current type of view of this form.                                                                                                                                    |

## Methods Summarized

| Type                                                                     | Name                                                                                                                                                  | Summary                                                                                                                |
| ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)               | [find()](#find)                                                                                                                                       | Set the foundset in find mode.                                                                                         |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)               | [focusField(fieldName, skipReadonly)](#focusfield-fieldname-skipreadonly)                                                                             | Sets focus to a field specified by its name.                                                                           |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)               | [focusFirstField()](#focusfirstfield)                                                                                                                 | Sets focus to the first field of the form; based on tab order sequence.                                                |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)                 | [getDataProviderMaxLength(name)](#getdataprovidermaxlength-name)                                                                                      | Returns the maximum length allowed in the specified dataprovider.                                                      |
| [Object](/reference/servoycore/dev-api/js-lib/object.md)                 | [getDataProviderValue(dataProvider)](#getdataprovidervalue-dataprovider)                                                                              | Gets a value based on the specified dataprovider name.                                                                 |
| [String](/reference/servoycore/dev-api/js-lib/string.md)                 | [getDataSource()](#getdatasource)                                                                                                                     | Get the used datasource.                                                                                               |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)               | [getDesignMode()](#getdesignmode)                                                                                                                     | Returns the state of this form designmode.                                                                             |
| [Object](/reference/servoycore/dev-api/js-lib/object.md)                 | [getDesignProperties()](#getdesignproperties)                                                                                                         | Get the design-time properties of the form.                                                                            |
| [Object](/reference/servoycore/dev-api/js-lib/object.md)                 | [getDesignTimeProperty(key)](#getdesigntimeproperty-key)                                                                                              | Get a design-time property of a form.                                                                                  |
| [JSDataSet](/reference/servoycore/dev-api/database-manager/jsdataset.md) | [getFormContext()](#getformcontext)                                                                                                                   | Gets the forms context where it resides, returns a dataset of its structure to the main controller.                    |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)                 | [getFormWidth()](#getformwidth)                                                                                                                       | Gets the form width in pixels.                                                                                         |
| [String](/reference/servoycore/dev-api/js-lib/string.md)                 | [getName()](#getname)                                                                                                                                 | Get the name of this form.                                                                                             |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)                 | [getPartHeight(partType)](#getpartheight-parttype)                                                                                                    | Gets the part height in pixels.                                                                                        |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)                 | [getPartYOffset(partType)](#getpartyoffset-parttype)                                                                                                  | Returns the Y offset of a given part of the form.                                                                      |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)                 | [getSelectedIndex()](#getselectedindex)                                                                                                               | Gets the current record index of the current foundset.                                                                 |
| [Array](/reference/servoycore/dev-api/js-lib/array.md)                   | [getTabSequence()](#gettabsequence)                                                                                                                   | Get an array with the names of the components that are part of the tab sequence.                                       |
| [JSWindow](/reference/servoycore/dev-api/application/jswindow.md)        | [getWindow()](#getwindow)                                                                                                                             | Returns the JSWindow that the form is shown in, or null if the form is not currently showing in a window.              |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)               | [loadAllRecords()](#loadallrecords)                                                                                                                   | Loads all accessible records from the datasource into the form foundset.                                               |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)               | [loadRecords(foundset)](#loadrecords-foundset)                                                                                                        | Loads a (related) foundset into the form.                                                                              |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)               | [loadRecords(foundset)](#loadrecords-foundset)                                                                                                        | Loads a (related) foundset into the form.                                                                              |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)               | [recreateUI()](#recreateui)                                                                                                                           | Recreates the forms UI components, to reflect the latest solution model.                                               |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)                 | [search()](#search)                                                                                                                                   | Start the database search and use the results, returns the number of records, make sure you did "find" function first. |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)                 | [search(clearLastResults)](#search-clearlastresults)                                                                                                  | Start the database search and use the results, returns the number of records, make sure you did "find" function first. |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)                 | [search(clearLastResults, reduceSearch)](#search-clearlastresults-reducesearch)                                                                       | Start the database search and use the results, returns the number of records, make sure you did "find" function first. |
| void                                                                     | [setDataProviderValue(dataprovider, value)](#setdataprovidervalue-dataprovider-value)                                                                 | Sets the value based on a specified dataprovider name.                                                                 |
| void                                                                     | [setDesignMode(designMode)](#setdesignmode-designmode)                                                                                                | Sets this form in designmode with param true, false will return to normal browse/edit mode.                            |
| void                                                                     | [setDesignMode(ondrag)](#setdesignmode-ondrag)                                                                                                        | Sets this form in designmode with one or more callback methods.                                                        |
| void                                                                     | [setDesignMode(ondrag, ondrop)](#setdesignmode-ondrag-ondrop)                                                                                         | Sets this form in designmode with one or more callback methods.                                                        |
| void                                                                     | [setDesignMode(ondrag, ondrop, onselect)](#setdesignmode-ondrag-ondrop-onselect)                                                                      | Sets this form in designmode with one or more callback methods.                                                        |
| void                                                                     | [setDesignMode(ondrag, ondrop, onselect, onresize)](#setdesignmode-ondrag-ondrop-onselect-onresize)                                                   | Sets this form in designmode with one or more callback methods.                                                        |
| void                                                                     | [setDesignMode(ondrag, ondrop, onselect, onresize, ondblclick)](#setdesignmode-ondrag-ondrop-onselect-onresize-ondblclick)                            | Sets this form in designmode with one or more callback methods.                                                        |
| void                                                                     | [setDesignMode(ondrag, ondrop, onselect, onresize, ondblclick, onrightclick)](#setdesignmode-ondrag-ondrop-onselect-onresize-ondblclick-onrightclick) | Sets this form in designmode with one or more callback methods.                                                        |
| void                                                                     | [setSelectedIndex(index)](#setselectedindex-index)                                                                                                    | Sets the current record index of the current foundset.                                                                 |
| void                                                                     | [setTabSequence(arrayOfElements)](#settabsequence-arrayofelements)                                                                                    | Set the tab order sequence programatically, by passing the elements references in a javascript array.                  |
| void                                                                     | [show()](#show)                                                                                                                                       | Shows the form (makes the form visible) This function does not affect the form foundset in any way.                    |
| void                                                                     | [show(window)](#show-window)                                                                                                                          | Shows the form (makes the form visible) This function does not affect the form foundset in any way.                    |
| void                                                                     | [show(window)](#show-window)                                                                                                                          | Shows the form (makes the form visible) This function does not affect the form foundset in any way.                    |
| void                                                                     | [showRecords(foundset)](#showrecords-foundset)                                                                                                        | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(foundset, window)](#showrecords-foundset-window)                                                                                         | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(foundset, window)](#showrecords-foundset-window)                                                                                         | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(pkdataset)](#showrecords-pkdataset)                                                                                                      | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(pkdataset, window)](#showrecords-pkdataset-window)                                                                                       | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(pkdataset, window)](#showrecords-pkdataset-window)                                                                                       | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(query)](#showrecords-query)                                                                                                              | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(query, window)](#showrecords-query-window)                                                                                               | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(query, window)](#showrecords-query-window)                                                                                               | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(UUIDpk)](#showrecords-uuidpk)                                                                                                            | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(UUIDpk, window)](#showrecords-uuidpk-window)                                                                                             | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(UUIDpk, window)](#showrecords-uuidpk-window)                                                                                             | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(singleNumber\_pk)](#showrecords-singlenumber_pk)                                                                                         | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(singleNumber\_pk, window)](#showrecords-singlenumber_pk-window)                                                                          | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(singleNumber\_pk, window)](#showrecords-singlenumber_pk-window)                                                                          | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(query)](#showrecords-query)                                                                                                              | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(query, window)](#showrecords-query-window)                                                                                               | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(query, argumentsArray)](#showrecords-query-argumentsarray)                                                                               | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(query, argumentsArray, window)](#showrecords-query-argumentsarray-window)                                                                | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(query, argumentsArray, window)](#showrecords-query-argumentsarray-window)                                                                | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |
| void                                                                     | [showRecords(query, window)](#showrecords-query-window)                                                                                               | Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.                  |

## Properties Detailed

### enabled

Gets or sets the enabled state of a form; also known as "grayed-out". Notes:

* A disabled element(s) cannot be selected by clicking the form.

**Type**\
[Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) true if the form is enabled (not grayed-out), false otherwise.

**Sample**

```js
//gets the enabled state of the form
var state = controller.enabled;
//enables the form for input
controller.enabled = true;
```

### readOnly

Gets or sets the read-only state of a form; also known as "editable"

Note: The field(s) in a form set as read-only can be selected and the field data can be copied to clipboard.

**Type**\
[Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) true if the form is read-only (not editable), false otherwise.

**Sample**

```js
//gets the read-only state of the form
var state = controller.readOnly;
//sets the read-only state of the form
controller.readOnly = true
```

### view

Get/Set the current type of view of this form. Can be one of the JSForm.xxxx\_VIEW constants.\
In NGClient only RECORD\_VIEW is fully supported, the List and TableViews should be replaced by components.

**Type**\
[Number](/reference/servoycore/dev-api/js-lib/number.md) the current view type of the form as an integer (e.g., RECORD\_VIEW, LIST\_VIEW).

**Sample**

```js
//gets the type of view for this form
var view = controller.view;
//sets the form to Record view
controller.view = JSForm.RECORD_VIEW;
//sets the form to List view
controller.view = JSForm.LIST_VIEW;
```

## Methods Detailed

### find()

```
Set the foundset in find mode. (Start a find request), use the "search" function to perform/exit the find.

Before going into find mode, all unsaved records will be saved in the database.
If this fails (due to validation failures or sql errors) or is not allowed (autosave off), the foundset will not go into find mode.
Make sure the operator and the data (value) are part of the string passed to dataprovider (included inside a pair of quotation marks).
Note: always make sure to check the result of the find() method.

When in find mode, columns can be assigned string expressions (including operators) that are evaluated as:
General:
      c1||c2    (condition1 or condition2)
      c|format  (apply format on condition like 'x|dd-MM-yyyy')
      !c        (not condition)
      #c        (modify condition, depends on column type)
      ^         (is null)
      ^=        (is null or empty)
      <x        (less than value x)
      >x        (greater than value x)
      <=x       (less than or equals value x)
      >=x       (greater than or equals value x)
      x...y     (between values x and y, including values)
      x         (equals value x)

 Number fields:
      =x       (equals value x)
      ^=       (is null or zero)

 Date fields:
      #c       (equals value x, entire day)
      now      (equals now, date and or time)
      //       (equals today)
      today    (equals today)

 Text fields:
      #c      (case insensitive condition)
      = x     (equals a space and 'x')
      ^=      (is null or empty)
      %x%     (contains 'x')
      %x_y%   (contains 'x' followed by any char and 'y')
      \%      (contains char '%')
      \_      (contains char '_')

Related columns can be assigned, they will result in related searches.
For example, "employees_to_department.location_id = headoffice" finds all employees in the specified location).

Searching on related aggregates is supported.
For example, "orders_to_details.total_amount = '>1000'" finds all orders with total order details amount more than 1000.

Arrays can be used for searching a number of values, this will result in an 'IN' condition that will be used in the search.
The values are not restricted to strings but can be any type that matches the column type.
For example, "record.department_id = [1, 33, 99]"

Multiple Find Records for Logical OR:
It's important to note that when in Find Mode, a foundset will initially contain one record object.
However, multiple record objects may be used to articulate search criteria.
This has the effect that the criteria described in each record are concatenated by a SQL OR.
```

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) true if the foundset is now in find mode, false otherwise.

**Sample**

```js
if (foundset.find()) //find will fail if autosave is disabled and there are unsaved records
{
	columnTextDataProvider = 'a search value'
	// for numbers you have to make sure to format it correctly so that the decimal point is in your locales notation (. or ,)
	columnNumberDataProvider = '>' + utils.numberFormat(anumber, '####.00');
	columnDateDataProvider = '31-12-2010|dd-MM-yyyy'
	foundset.search()
}

// Multiple Find Records for Logical OR - example
// Find customers in the city of Berlin AND in the postal code 12209...
// OR customers in the city of San Francisco AND in the postal code 94117
if (foundset.find()) // Enter find mode    city = 'Berlin';
{
	city = 'Berlin';   // Assign a search criteria
	postalcode = '12209';
	foundset.newRecord();   // Create a new search record
	city = 'San Francisco';
	postalcode = '94117';
	foundset.search();      // Execute the query and load the records
}
```

### focusField(fieldName, skipReadonly)

Sets focus to a field specified by its name.\
If the second parameter is set to true, then readonly fields will be skipped\
(the focus will be set to the first non-readonly field located after the field with the specified name; the tab sequence is respected when searching for the non-readonly field).

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **fieldName** the name of the field to be focussed
* [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) **skipReadonly** indication to skip read only fields, if the named field happens to be read only

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) true if component was found and can be focused

**Sample**

```js
var tabseq = controller.getTabSequence();
if (tabseq.length > 1) {
	// If there is more than one field in the tab sequence,
	// focus the second one and skip over readonly fields.
	controller.focusField(tabseq[1], true);
}
else {
	// If there is at most one field in the tab sequence, then focus
	// whatever field is first, and don't bother to skip over readonly fields.
	controller.focusField(null, false);
}
```

### focusFirstField()

Sets focus to the first field of the form; based on tab order sequence.

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) true if component was found and can be focused

**Sample**

```js
controller.focusFirstField();
```

### getDataProviderMaxLength(name)

Returns the maximum length allowed in the specified dataprovider.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **name** the dataprovider name

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the length

**Sample**

```js
controller.getDataProviderMaxLength('name');
```

### getDataProviderValue(dataProvider)

Gets a value based on the specified dataprovider name.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **dataProvider** the dataprovider name to retieve the value for

**Returns:** [Object](/reference/servoycore/dev-api/js-lib/object.md) the dataprovider value (null if unknown dataprovider)

**Sample**

```js
var val = controller.getDataProviderValue('contact_name');
```

### getDataSource()

Get the used datasource.

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md) the datasource

**Sample**

```js
var dataSource = controller.getDataSource();
```

### getDesignMode()

Returns the state of this form designmode.

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) the design mode state (true/fase)

**Sample**

```js
var success = controller.getDesignMode();
```

### getDesignProperties()

Get the design-time properties of the form.

**Returns:** [Object](/reference/servoycore/dev-api/js-lib/object.md) a map containing all design-time properties of the form.

**Sample**

```js
var prop = fforms.orders.controller.getDesignProperties()
```

### getDesignTimeProperty(key)

Get a design-time property of a form.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **key** the property name

**Returns:** [Object](/reference/servoycore/dev-api/js-lib/object.md) the value of the specified design-time property, or null if the property is not set.

**Sample**

```js
var prop = forms.orders.controller.getDesignTimeProperty('myprop')
```

### getFormContext()

Gets the forms context where it resides, returns a dataset of its structure to the main controller.\
Note1: can't be called in onload, because no context is yet available at this time.\
Note2: tabindex is 1 (left) or 2 (right) for a SplitPane and 0 based for the other tabpanels; tabindex1based is the same as tabindex but is 1 based.

**Returns:** [JSDataSet](/reference/servoycore/dev-api/database-manager/jsdataset.md) the dataset with form context

**Sample**

```js
//dataset columns: [containername(1),formname(2),tabpanel or beanname(3),tabname(4),tabindex(5),tabindex1based(6)]
//dataset rows: mainform(1) -> parent(2)  -> current form(3) (when 3 forms deep)
/** @type {JSDataSet} */
var dataset = controller.getFormContext();
if (dataset.getMaxRowIndex() > 1)
{
	// form is in a tabpanel
	var parentFormName = dataset.getValue(1,2)
}
```

### getFormWidth()

Gets the form width in pixels.

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the width in pixels

**Sample**

```js
var width = controller.getFormWidth();
```

### getName()

Get the name of this form.

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md) the name

**Sample**

```js
var formName = controller.getName();
```

### getPartHeight(partType)

Gets the part height in pixels.

**Parameters**

* [Number](/reference/servoycore/dev-api/js-lib/number.md) **partType** The type of the part whose height will be returned.

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the part height in pixels

**Sample**

```js
var height = controller.getPartHeight(JSPart.BODY);
```

### getPartYOffset(partType)

Returns the Y offset of a given part of the form.

**Parameters**

* [Number](/reference/servoycore/dev-api/js-lib/number.md) **partType** The type of the part whose Y offset will be returned.

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) A number holding the Y offset of the specified form part.

**Sample**

```js
var offset = controller.getPartYOffset(JSPart.BODY);
```

### getSelectedIndex()

Gets the current record index of the current foundset.

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the index

**Sample**

```js
//gets the current record index in the current foundset
var current = controller.getSelectedIndex();
//sets the next record in the foundset, will be reflected in UI
controller.setSelectedIndex(current+1);
```

### getTabSequence()

Get an array with the names of the components that are part of the tab sequence.\
The order of the names respects the order of the tab sequence.\
Components that are not named will not appear in the returned array, although they may be in the tab sequence.

**Returns:** [Array](/reference/servoycore/dev-api/js-lib/array.md) array of names

**Sample**

```js
var tabseq = controller.getTabSequence();
if (tabseq.length > 1) {
	// If there is more than one field in the tab sequence,
	// focus the second one and skip over readonly fields.
	controller.focusField(tabseq[1], true);
}
else {
	// If there is at most one field in the tab sequence, then focus
	// whatever field is first, and don't bother to skip over readonly fields.
	controller.focusField(null, false);
}
```

### getWindow()

Returns the JSWindow that the form is shown in, or null if the form is not currently showing in a window.

**Returns:** [JSWindow](/reference/servoycore/dev-api/application/jswindow.md) the JSWindow that the form is shown in, or null if the form is not currently showing in a window.

**Sample**

```js
var currentWindow = controller.getWindow();
if (currentWindow != null) {
	currentWindow.title = 'We have a new title';
} else {
	currentWindow = application.createWindow("Window Name", JSWindow.DIALOG, null);
	currentWindow(650, 700, 450, 350);
	currentWindow = "Window Title";
	controller.show(currentWindow);
}
```

### loadAllRecords()

Loads all accessible records from the datasource into the form foundset.\
When the form contains a related foundset it will be replaced by a default foundset on same datasource.\
Or when this form is not configured to have a seperate foundset it will also be related with the default shared foundset.

So this is different then foundset.loadAllRecords() because that will just load all the records based on its filters of that foundset instance.\
This controller.loadAllRecords() can result in a replacement of the current loaded foundset instance.

Notes:\
-the default foundset is always limited by filters, if databaseManager.addFoundSetFilterParam function is used.\
-typical use is loading the normal foundset again after form usage in a related tabpanel

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) true if successful

**Sample**

```js
controller.loadAllRecords();
```

### loadRecords(foundset)

Loads a (related) foundset into the form. The form will no longer share the default foundset with forms of the same datasource, use controller.loadAllRecords() to restore the default foundset. (restore to default foundset depends a bit on if the give foundset is a related foundset or not or if this form is configured to have a seperated foundset)

This will really change the foundset instance itself of the form, so no existing foundset is altered just the new foundset that is given is used.. This is different then doing foundset.loadRecords(foundset) because that just alters the current foundset and doesn't do anything with the foundset that is given.

controller.loadRecords( relation ) will always replace with related fs \[default]controller.loadRecords( fs ) will replace default fs with the given foundset, foundset filters set previously on the forms foundset are gone, only the foundset filters on the given foundset are set. \[separate/named]controller.loadRecords( fs ) will behave like foundset.loadRecords(fs) if the form has already a separate/named foundset but foundset filters set previously on the forms foundset are gone, only the foundset filters on the given foundset are set.

foundset.loadRecords(fs) will adjust the current forms foundset and the foundset filters that are set are kept and merged with the filters of the given foundset.

**Parameters**

* [JSFoundSet](/reference/servoycore/dev-api/database-manager/jsfoundset.md) **foundset** to load

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) true if successful

**Sample**

```js
//to load a (related)foundset into the form.
//the form will no longer share the default foundset with forms of the same datasource, use loadAllRecords to restore the default foundset
controller.loadRecords(order_to_orderdetails);
```

### loadRecords(foundset)

Loads a (related) foundset into the form.\
The form will no longer share the default foundset with forms of the same datasource, use loadAllRecords to restore the default foundset.

This will really update the foundset instance itself of the form, so now existing foundset is altered just the new foundset is shown.\
This is different then doing foundset.loadRecords(foundset) because that just alters the current foundset and doesn't do anything with the foundset\
that is given.

When the form uses a seperate foundset, foundset filter params are copied over from the source foundset and are merged with the existing filters.

**Parameters**

* [JSFoundSet](/reference/servoycore/dev-api/database-manager/jsfoundset.md) **foundset** to load

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) true if successful

**Sample**

```js
//to load a (related)foundset into the form.
//the form will no longer share the default foundset with forms of the same datasource, use loadAllRecords to restore the default foundset
controller.loadRecords(order_to_orderdetails);
```

### recreateUI()

Recreates the forms UI components, to reflect the latest solution model.\
Use this after altering the elements via solutionModel at the JSForm of this form.

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) true if successful

**Sample**

```js
// get the solution model JSForm
var form = solutionModel.getForm("myForm");
// get the JSField of the form
var field = form.getField("myField");
// alter the field
field.x = field.x + 10;
// recreate the runtime forms ui to reflect the changes.
controller.recreateUI();
```

### search()

Start the database search and use the results, returns the number of records, make sure you did "find" function first.\
Clear results from previous searches.

Note: Omitted records are automatically excluded when performing a search - meaning that the foundset result by default will not include omitted records.

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the recordCount

**Sample**

```js
var recordCount = foundset.search();
//var recordCount = foundset.search(false,false); //to extend foundset
```

### search(clearLastResults)

Start the database search and use the results, returns the number of records, make sure you did "find" function first.\
Reduce results from previous searches.

Note: Omitted records are automatically excluded when performing a search - meaning that the foundset result by default will not include omitted records.

**Parameters**

* [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) **clearLastResults** boolean, clear previous search, default true

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the recordCount

**Sample**

```js
var recordCount = foundset.search();
//var recordCount = foundset.search(false,false); //to extend foundset
```

### search(clearLastResults, reduceSearch)

Start the database search and use the results, returns the number of records, make sure you did "find" function first.

Note: Omitted records are automatically excluded when performing a search - meaning that the foundset result by default will not include omitted records.

**Parameters**

* [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) **clearLastResults** boolean, clear previous search, default true
* [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) **reduceSearch** boolean, reduce (true) or extend (false) previous search results, default true

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the recordCount

**Sample**

```js
var recordCount = foundset.search();
//var recordCount = foundset.search(false,false); //to extend foundset
```

### setDataProviderValue(dataprovider, value)

Sets the value based on a specified dataprovider name.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **dataprovider** the dataprovider name to set the value for
* [Object](/reference/servoycore/dev-api/js-lib/object.md) **value** the value to set in the dataprovider

**Returns:** void

**Sample**

```js
controller.setDataProviderValue('contact_name','mycompany');
```

### setDesignMode(designMode)

Sets this form in designmode with param true, false will return to normal browse/edit mode.

**Parameters**

* [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) **designMode** sets form in design mode if true, false ends design mode.

**Returns:** void

**Sample**

```js
var form = forms["selectedFormName"];
if (!form.controller.getDesignMode())
{
	// Set the current form in designmode with no callbacks
	form.controller.setDesignMode(true);
	// Set the current form in designmode with callbacks
	// where onDrag, onDrop, onSelect, onResize are names of form methods (not from "selectedFormName" form)
	// form.controller.setDesignMode(onDrag, onDrop, onSelect, onResize);
}
//Set the current form out of designmode (to normal browse)
//form.controller.setDesignMode(false);
```

### setDesignMode(ondrag)

Sets this form in designmode with one or more callback methods.

**Parameters**

* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrag** onDrag method reference

**Returns:** void

**Sample**

```js
var form = forms["selectedFormName"];
if (!form.controller.getDesignMode())
{
	// Set the current form in designmode with no callbacks
	form.controller.setDesignMode(true);
	// Set the current form in designmode with callbacks
	// where onDrag, onDrop, onSelect, onResize are names of form methods (not from "selectedFormName" form)
	// form.controller.setDesignMode(onDrag, onDrop, onSelect, onResize);
}
//Set the current form out of designmode (to normal browse)
//form.controller.setDesignMode(false);
```

### setDesignMode(ondrag, ondrop)

Sets this form in designmode with one or more callback methods.

**Parameters**

* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrag** onDrag method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrop** onDrop method reference

**Returns:** void

**Sample**

```js
var form = forms["selectedFormName"];
if (!form.controller.getDesignMode())
{
	// Set the current form in designmode with no callbacks
	form.controller.setDesignMode(true);
	// Set the current form in designmode with callbacks
	// where onDrag, onDrop, onSelect, onResize are names of form methods (not from "selectedFormName" form)
	// form.controller.setDesignMode(onDrag, onDrop, onSelect, onResize);
}
//Set the current form out of designmode (to normal browse)
//form.controller.setDesignMode(false);
```

### setDesignMode(ondrag, ondrop, onselect)

Sets this form in designmode with one or more callback methods.

**Parameters**

* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrag** onDrag method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrop** onDrop method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **onselect** onSelect method reference

**Returns:** void

**Sample**

```js
var form = forms["selectedFormName"];
if (!form.controller.getDesignMode())
{
	// Set the current form in designmode with no callbacks
	form.controller.setDesignMode(true);
	// Set the current form in designmode with callbacks
	// where onDrag, onDrop, onSelect, onResize are names of form methods (not from "selectedFormName" form)
	// form.controller.setDesignMode(onDrag, onDrop, onSelect, onResize);
}
//Set the current form out of designmode (to normal browse)
//form.controller.setDesignMode(false);
```

### setDesignMode(ondrag, ondrop, onselect, onresize)

Sets this form in designmode with one or more callback methods.

**Parameters**

* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrag** onDrag method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrop** onDrop method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **onselect** onSelect method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **onresize** onResize method reference

**Returns:** void

**Sample**

```js
var form = forms["selectedFormName"];
if (!form.controller.getDesignMode())
{
	// Set the current form in designmode with no callbacks
	form.controller.setDesignMode(true);
	// Set the current form in designmode with callbacks
	// where onDrag, onDrop, onSelect, onResize are names of form methods (not from "selectedFormName" form)
	// form.controller.setDesignMode(onDrag, onDrop, onSelect, onResize);
}
//Set the current form out of designmode (to normal browse)
//form.controller.setDesignMode(false);
```

### setDesignMode(ondrag, ondrop, onselect, onresize, ondblclick)

Sets this form in designmode with one or more callback methods.

**Parameters**

* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrag** onDrag method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrop** onDrop method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **onselect** onSelect method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **onresize** onResize method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondblclick** onDblClick method reference

**Returns:** void

**Sample**

```js
var form = forms["selectedFormName"];
if (!form.controller.getDesignMode())
{
	// Set the current form in designmode with no callbacks
	form.controller.setDesignMode(true);
	// Set the current form in designmode with callbacks
	// where onDrag, onDrop, onSelect, onResize are names of form methods (not from "selectedFormName" form)
	// form.controller.setDesignMode(onDrag, onDrop, onSelect, onResize);
}
//Set the current form out of designmode (to normal browse)
//form.controller.setDesignMode(false);
```

### setDesignMode(ondrag, ondrop, onselect, onresize, ondblclick, onrightclick)

Sets this form in designmode with one or more callback methods.

**Parameters**

* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrag** onDrag method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondrop** onDrop method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **onselect** onSelect method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **onresize** onResize method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **ondblclick** onDblClick method reference
* [Function](/reference/servoycore/dev-api/js-lib/function.md) **onrightclick** onRightClick method reference

**Returns:** void

**Sample**

```js
var form = forms["selectedFormName"];
if (!form.controller.getDesignMode())
{
	// Set the current form in designmode with no callbacks
	form.controller.setDesignMode(true);
	// Set the current form in designmode with callbacks
	// where onDrag, onDrop, onSelect, onResize are names of form methods (not from "selectedFormName" form)
	// form.controller.setDesignMode(onDrag, onDrop, onSelect, onResize);
}
//Set the current form out of designmode (to normal browse)
//form.controller.setDesignMode(false);
```

### setSelectedIndex(index)

Sets the current record index of the current foundset.

**Parameters**

* [Number](/reference/servoycore/dev-api/js-lib/number.md) **index** the index to select

**Returns:** void

**Sample**

```js
//gets the current record index in the current foundset
var current = controller.getSelectedIndex();
//sets the next record in the foundset, will be reflected in UI
controller.setSelectedIndex(current+1);
```

### setTabSequence(arrayOfElements)

Set the tab order sequence programatically, by passing the elements references in a javascript array.

**Parameters**

* [Array](/reference/servoycore/dev-api/js-lib/array.md) **arrayOfElements** array containing the element references

**Returns:** void

**Sample**

```js
controller.setTabSequence([elements.fld_order_id, elements.fld_order_amount]);
```

### show()

Shows the form (makes the form visible) This function does not affect the form foundset in any way.

**Returns:** void

**Sample**

```js
// show the form in the current window/dialog
controller.show();
// show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.show(w);
// show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.show(w);
// or controller.show("mydialog");
//show the form in the main window
//controller.show(null);
```

### show(window)

Shows the form (makes the form visible) This function does not affect the form foundset in any way.

**Parameters**

* [JSWindow](/reference/servoycore/dev-api/application/jswindow.md) **window** the window in which this form should be shown, given as a window object

**Returns:** void

**Sample**

```js
// show the form in the current window/dialog
controller.show();
// show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.show(w);
// show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.show(w);
// or controller.show("mydialog");
//show the form in the main window
//controller.show(null);
```

### show(window)

Shows the form (makes the form visible) This function does not affect the form foundset in any way.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **window** the window in which this form should be shown, specified by the name of an existing window

**Returns:** void

**Sample**

```js
// show the form in the current window/dialog
controller.show();
// show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.show(w);
// show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.show(w);
// or controller.show("mydialog");
//show the form in the main window
//controller.show(null);
```

### showRecords(foundset)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [JSFoundSet](/reference/servoycore/dev-api/database-manager/jsfoundset.md) **foundset** the foundset to load before showing the form.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(foundset, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [JSFoundSet](/reference/servoycore/dev-api/database-manager/jsfoundset.md) **foundset** the foundset to load before showing the form.
* [JSWindow](/reference/servoycore/dev-api/application/jswindow.md) **window** the window in which this form should be shown, given as a window object.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(foundset, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [JSFoundSet](/reference/servoycore/dev-api/database-manager/jsfoundset.md) **foundset** the foundset to load before showing the form.
* [String](/reference/servoycore/dev-api/js-lib/string.md) **window** the window in which this form should be shown, specified by the name of an existing window.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(pkdataset)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [JSDataSet](/reference/servoycore/dev-api/database-manager/jsdataset.md) **pkdataset** the pkdataset to load before showing the form.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(pkdataset, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [JSDataSet](/reference/servoycore/dev-api/database-manager/jsdataset.md) **pkdataset** the pkdataset to load before showing the form.
* [JSWindow](/reference/servoycore/dev-api/application/jswindow.md) **window** the window in which this form should be shown, given as a window object.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(pkdataset, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [JSDataSet](/reference/servoycore/dev-api/database-manager/jsdataset.md) **pkdataset** the pkdataset to load before showing the form.
* [String](/reference/servoycore/dev-api/js-lib/string.md) **window** the window in which this form should be shown, specified by the name of an existing window.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(query)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [QBSelect](/reference/servoycore/dev-api/database-manager/qbselect.md) **query** the query to load before showing the form.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(query, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [QBSelect](/reference/servoycore/dev-api/database-manager/qbselect.md) **query** the query to load before showing the form.
* [JSWindow](/reference/servoycore/dev-api/application/jswindow.md) **window** the window in which this form should be shown, given as a window object.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(query, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [QBSelect](/reference/servoycore/dev-api/database-manager/qbselect.md) **query** the query to load before showing the form.
* [String](/reference/servoycore/dev-api/js-lib/string.md) **window** the window in which this form should be shown, specified by the name of an existing window.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(UUIDpk)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [UUID](/reference/servoycore/dev-api/application/uuid.md) **UUIDpk** the UUIDpk to load before showing the form.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(UUIDpk, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [UUID](/reference/servoycore/dev-api/application/uuid.md) **UUIDpk** the UUIDpk to load before showing the form.
* [JSWindow](/reference/servoycore/dev-api/application/jswindow.md) **window** the window in which this form should be shown, given as a window object.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(UUIDpk, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [UUID](/reference/servoycore/dev-api/application/uuid.md) **UUIDpk** the UUIDpk to load before showing the form.
* [String](/reference/servoycore/dev-api/js-lib/string.md) **window** the window in which this form should be shown, specified by the name of an existing window.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(singleNumber\_pk)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [Number](/reference/servoycore/dev-api/js-lib/number.md) **singleNumber\_pk** the singleNumber\_pk to load before showing the form.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(singleNumber\_pk, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [Number](/reference/servoycore/dev-api/js-lib/number.md) **singleNumber\_pk** the singleNumber\_pk to load before showing the form.
* [JSWindow](/reference/servoycore/dev-api/application/jswindow.md) **window** the window in which this form should be shown, given as a window object

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(singleNumber\_pk, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [Number](/reference/servoycore/dev-api/js-lib/number.md) **singleNumber\_pk** the singleNumber\_pk to load before showing the form.
* [String](/reference/servoycore/dev-api/js-lib/string.md) **window** the window in which this form should be shown, specified by the name of an existing window.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(query)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **query** the query to load before showing the form.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(query, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **query** the query to load before showing the form.
* [JSWindow](/reference/servoycore/dev-api/application/jswindow.md) **window** the window in which this form should be shown, given as a window object

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(query, argumentsArray)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **query** the query to load before showing the form.
* [Array](/reference/servoycore/dev-api/js-lib/array.md) **argumentsArray** the array of arguments for the query

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(query, argumentsArray, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **query** the query to load before showing the form.
* [Array](/reference/servoycore/dev-api/js-lib/array.md) **argumentsArray** the array of arguments for the query
* [JSWindow](/reference/servoycore/dev-api/application/jswindow.md) **window** the window in which this form should be shown, given as a window object

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(query, argumentsArray, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **query** the query to load before showing the form.
* [Array](/reference/servoycore/dev-api/js-lib/array.md) **argumentsArray** the array of arguments for the query
* [String](/reference/servoycore/dev-api/js-lib/string.md) **window** the window in which this form should be shown, specified by the name of an existing window.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

### showRecords(query, window)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **query** the query to load before showing the form.
* [String](/reference/servoycore/dev-api/js-lib/string.md) **window** the window in which this form should be shown, specified by the name of an existing window.

**Returns:** void

**Sample**

```js
controller.showRecords(foundset);
// load foundset & show the form in newly created named modal dialog
var w = application.createWindow("mydialog", JSWindow.MODAL_DIALOG);
controller.showRecords(foundset, w);
// load foundset & show the form in an existing window/dialog
var w = application.getWindow("mydialog"); // use null name for main app. window
controller.showRecords(foundset, w);
//controller.showRecords(foundset, "mydialog");
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoycore/dev-api/forms/runtimeform/controller.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
