acquireLock(foundset, recordIndex)

Request lock(s) for a foundset, can be a normal or related foundset.
The record_index can be -1 to lock all rows, 0 to lock the current row, or a specific row of > 0
Optionally name the lock(s) so that it can be referenced it in releaseAllLocks()
returns true if the lock could be acquired.

//locks the complete foundset
databaseManager.acquireLock(foundset,-1);
//locks the current row
databaseManager.acquireLock(foundset,0);
//locks all related orders for the current Customer
var success = databaseManager.acquireLock(Cust_to_Orders,-1);
if(!success)
{
plugins.dialogs.showWarningDialog('Alert','Failed to get a lock','OK');
}

acquireLock(foundset, recordIndex, lockName)

Request lock(s) for a foundset, can be a normal or related foundset.
The record_index can be -1 to lock all rows, 0 to lock the current row, or a specific row of > 0
Optionally name the lock(s) so that it can be referenced it in releaseAllLocks()
returns true if the lock could be acquired.

//locks the complete foundset
databaseManager.acquireLock(foundset,-1);
//locks the current row
databaseManager.acquireLock(foundset,0);
//locks all related orders for the current Customer
var success = databaseManager.acquireLock(Cust_to_Orders,-1);
if(!success)
{
plugins.dialogs.showWarningDialog('Alert','Failed to get a lock','OK');
}

addTableFilterParam(query)

Adds a filter based on a query to all the foundsets based on a table.
Filters on tables touched in the query will not be applied to the query filter.
For example, when a table filter exists on the order_details table,
a query filter with a join from orders to order_details will be applied to queries on the orders table,
but the filter condition on the orders_details table will not be included.
returns true if the tablefilter could be applied.

// Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that
var query = datasources.db.example_data.orders.createSelect();
query.where.add(
query.or.add(
query.columns.shipcity.eq('Amersfoort'))
.add( query.columns.shipcity.eq('Amsterdam')));
var success = databaseManager.addTableFilterParam(query, 'cityFilter')

addTableFilterParam(query, filterName)

Adds a filter based on a query to all the foundsets based on a table.
Filters on tables touched in the query will not be applied to the query filter.
For example, when a table filter exists on the order_details table,
a query filter with a join from orders to order_details will be applied to queries on the orders table,
but the filter condition on the orders_details table will not be included.
returns true if the tablefilter could be applied.

// Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that
var query = datasources.db.example_data.orders.createSelect();
query.where.add(
query.or.add(
query.columns.shipcity.eq('Amersfoort'))
.add( query.columns.shipcity.eq('Amsterdam')));
var success = databaseManager.addTableFilterParam(query, 'cityFilter')

addTableFilterParam(datasource, dataprovider, operator, value)

Adds a filter to all the foundsets based on a table.
Note: if null is provided as the tablename the filter will be applied on all tables with the dataprovider name.
A dataprovider can have multiple filters defined, they will all be applied.
returns true if the tablefilter could be applied.

// Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that multiple filters can be added to the same dataprovider, they will all be applied.
// filter on messages table where messagesid>10, the filter has a name so it can be removed using databaseManager.removeTableFilterParam()
var success = databaseManager.addTableFilterParam('admin', 'messages', 'messagesid', '>', 10, 'higNumberedMessagesRule')
// all tables that have the companyid column should be filtered
var success = databaseManager.addTableFilterParam('crm', null, 'companyidid', '=', currentcompanyid)
// some filters with in-conditions
var success = databaseManager.addTableFilterParam('crm', 'products', 'productcode', 'in', [120, 144, 200])
var success = databaseManager.addTableFilterParam('crm', 'orders', 'countrycode', 'in', 'select country code from countries where region = "Europe"')
// you can use modifiers in the operator as well, filter on companies where companyname is null or equals-ignore-case 'servoy'
var success = databaseManager.addTableFilterParam('crm', 'companies', 'companyname', '#^||=', 'servoy')
// the value may be null, this will result in 'column is null' sql condition.
var success = databaseManager.addTableFilterParam('crm', 'companies', 'verified', '=', null)
//if you want to add a filter for a column (created by you) in the i18n table
databaseManager.addTableFilterParam('database', 'your_i18n_table', 'message_variant', 'in', [1, 2])

Adds a filter to all the foundsets based on a table.
Note: if null is provided as the tablename the filter will be applied on all tables with the dataprovider name.
A dataprovider can have multiple filters defined, they will all be applied.
returns true if the tablefilter could be applied.

// Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that multiple filters can be added to the same dataprovider, they will all be applied.
// filter on messages table where messagesid>10, the filter has a name so it can be removed using databaseManager.removeTableFilterParam()
var success = databaseManager.addTableFilterParam('admin', 'messages', 'messagesid', '>', 10, 'higNumberedMessagesRule')
// all tables that have the companyid column should be filtered
var success = databaseManager.addTableFilterParam('crm', null, 'companyidid', '=', currentcompanyid)
// some filters with in-conditions
var success = databaseManager.addTableFilterParam('crm', 'products', 'productcode', 'in', [120, 144, 200])
var success = databaseManager.addTableFilterParam('crm', 'orders', 'countrycode', 'in', 'select country code from countries where region = "Europe"')
// you can use modifiers in the operator as well, filter on companies where companyname is null or equals-ignore-case 'servoy'
var success = databaseManager.addTableFilterParam('crm', 'companies', 'companyname', '#^||=', 'servoy')
// the value may be null, this will result in 'column is null' sql condition.
var success = databaseManager.addTableFilterParam('crm', 'companies', 'verified', '=', null)
//if you want to add a filter for a column (created by you) in the i18n table
databaseManager.addTableFilterParam('database', 'your_i18n_table', 'message_variant', 'in', [1, 2])

Adds a filter to all the foundsets based on a table.
Note: if null is provided as the tablename the filter will be applied on all tables with the dataprovider name.
A dataprovider can have multiple filters defined, they will all be applied.
returns true if the tablefilter could be applied.

// Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that multiple filters can be added to the same dataprovider, they will all be applied.
// filter on messages table where messagesid>10, the filter has a name so it can be removed using databaseManager.removeTableFilterParam()
var success = databaseManager.addTableFilterParam('admin', 'messages', 'messagesid', '>', 10, 'higNumberedMessagesRule')
// all tables that have the companyid column should be filtered
var success = databaseManager.addTableFilterParam('crm', null, 'companyidid', '=', currentcompanyid)
// some filters with in-conditions
var success = databaseManager.addTableFilterParam('crm', 'products', 'productcode', 'in', [120, 144, 200])
var success = databaseManager.addTableFilterParam('crm', 'orders', 'countrycode', 'in', 'select country code from countries where region = "Europe"')
// you can use modifiers in the operator as well, filter on companies where companyname is null or equals-ignore-case 'servoy'
var success = databaseManager.addTableFilterParam('crm', 'companies', 'companyname', '#^||=', 'servoy')
// the value may be null, this will result in 'column is null' sql condition.
var success = databaseManager.addTableFilterParam('crm', 'companies', 'verified', '=', null)
//if you want to add a filter for a column (created by you) in the i18n table
databaseManager.addTableFilterParam('database', 'your_i18n_table', 'message_variant', 'in', [1, 2])

Adds a filter to all the foundsets based on a table.
Note: if null is provided as the tablename the filter will be applied on all tables with the dataprovider name.
A dataprovider can have multiple filters defined, they will all be applied.
returns true if the tablefilter could be applied.

// Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that multiple filters can be added to the same dataprovider, they will all be applied.
// filter on messages table where messagesid>10, the filter has a name so it can be removed using databaseManager.removeTableFilterParam()
var success = databaseManager.addTableFilterParam('admin', 'messages', 'messagesid', '>', 10, 'higNumberedMessagesRule')
// all tables that have the companyid column should be filtered
var success = databaseManager.addTableFilterParam('crm', null, 'companyidid', '=', currentcompanyid)
// some filters with in-conditions
var success = databaseManager.addTableFilterParam('crm', 'products', 'productcode', 'in', [120, 144, 200])
var success = databaseManager.addTableFilterParam('crm', 'orders', 'countrycode', 'in', 'select country code from countries where region = "Europe"')
// you can use modifiers in the operator as well, filter on companies where companyname is null or equals-ignore-case 'servoy'
var success = databaseManager.addTableFilterParam('crm', 'companies', 'companyname', '#^||=', 'servoy')
// the value may be null, this will result in 'column is null' sql condition.
var success = databaseManager.addTableFilterParam('crm', 'companies', 'verified', '=', null)
//if you want to add a filter for a column (created by you) in the i18n table
databaseManager.addTableFilterParam('database', 'your_i18n_table', 'message_variant', 'in', [1, 2])

addTrackingInfo(columnName, value)

Add tracking info used in the log table.
When tracking is enabled and a new row is inserted in the log table,
if it has a column named 'columnName', its value will be set with 'value'

commitTransaction()

// starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
}

// starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
}

// starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
}

convertFoundSet(foundset, related)

Creates a foundset that combines all the records of the specified one-to-many relation seen from the given parent/primary foundset.
The created foundset will not contain records that have not been saved in the database, because the records in the foundset will be the
result of a select query to the database.

// Convert in the order form a orders foundset into a orderdetails foundset,
// that has all the orderdetails from all the orders in the foundset.
var convertedFoundSet = databaseManager.convertFoundSet(foundset,order_to_orderdetails);
// or var convertedFoundSet = databaseManager.convertFoundSet(foundset,"order_to_orderdetails");
forms.orderdetails.controller.showRecords(convertedFoundSet);

convertFoundSet(foundset, related)

Creates a foundset that combines all the records of the specified one-to-many relation seen from the given parent/primary foundset.
The created foundset will not contain records that have not been saved in the database, because the records in the foundset will be the
result of a select query to the database.

// Convert in the order form a orders foundset into a orderdetails foundset,
// that has all the orderdetails from all the orders in the foundset.
var convertedFoundSet = databaseManager.convertFoundSet(foundset,order_to_orderdetails);
// or var convertedFoundSet = databaseManager.convertFoundSet(foundset,"order_to_orderdetails");
forms.orderdetails.controller.showRecords(convertedFoundSet);

convertToDataSet(foundset)

Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset.

convertToDataSet(foundset, dataproviderNames)

Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset.

convertToDataSet(values)

Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset.

convertToDataSet(values, dataproviderNames)

Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset.

convertToDataSet(ids)

Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset.

copyMatchingFields(source, destination)

Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names).
The matching requires the properties and getter functions of the source to match those of the destination; for the getter functions,
the 'get' will be removed and the remaining name will be converted to lowercase before attempting to match.
Returns true if no error occurred.
NOTE: This function could be used to store a copy of records in an archive table. Use the getRecord() function to get the record as an object.
Before trying this example, please make sure that the foundsets have some records loaded:

copyMatchingFields(source, destination, overwrite)

Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names).
The matching requires the properties and getter functions of the source to match those of the destination; for the getter functions,
the 'get' will be removed and the remaining name will be converted to lowercase before attempting to match.
Returns true if no error occurred.
NOTE: This function could be used to store a copy of records in an archive table. Use the getRecord() function to get the record as an object.
Before trying this example, please make sure that the foundsets have some records loaded:

copyMatchingFields(source, destination, names)

Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names).
The matching requires the properties and getter functions of the source to match those of the destination; for the getter functions,
the 'get' will be removed and the remaining name will be converted to lowercase before attempting to match.
Returns true if no error occurred.
NOTE: This function could be used to store a copy of records in an archive table. Use the getRecord() function to get the record as an object.
Before trying this example, please make sure that the foundsets have some records loaded:

Performs a query and saves the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data.

createDataSourceByQuery(name, query, max_returned_rows)

Performs a query and saves the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data.

createDataSourceByQuery(name, query, max_returned_rows, types)

Performs a query and saves the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be taken into account.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data.

Performs a query and saves the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be taken into account.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data.

Performs a sql query on the specified server, saves the the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be disregarded.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data.

Performs a sql query on the specified server, saves the the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be disregarded.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data.

Performs a sql query on the specified server, saves the the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be disregarded.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data.

getAutoSave()

//Set autosave, if false then no saves will happen by the ui (not including deletes!). Until you call saveData or setAutoSave(true)
//Rollbacks in mem the records that were edited and not yet saved. Best used in combination with autosave false.
databaseManager.setAutoSave(false)
//Now let users input data
//On save or cancel, when data has been entered:
if (cancel) databaseManager.rollbackEditedRecords()
databaseManager.setAutoSave(true)

getDataModelClonesFrom(serverName)

Retrieves a list with names of all database servers that have property DataModelCloneFrom equal to the server name parameter.

getDataSetByQuery(query, max_returned_rows)

Performs a sql query with a query builder object.
Will throw an exception if anything did go wrong when executing the query.
Using this variation of getDataSetByQuery any Tablefilter on the involved tables will be taken into account.

Performs a sql query on the specified server, returns the result in a dataset.
Will throw an exception if anything did go wrong when executing the query.
Using this variation of getDataSetByQuery any Tablefilter on the involved tables will be disregarded.

getDatabaseProductName(serverName)

Returns the database product name as supplied by the driver for a server.
NOTE: For more detail on named server connections, see the chapter on Database Connections, beginning with the Introduction to database connections in the Servoy Developer User's Guide.

getEditedRecords()

Returns an array of edited records with outstanding (unsaved) data.
This is different form JSRecord.isEditing() because this call actually checks if there are changes between the current
record data and the stored data in the database. If there are no changes then the record is removed from the edited records
list (so after this call JSRecord.isEditing() can return false when it returned true just before this call)
NOTE: To return a dataset of outstanding (unsaved) edited data for each record, see JSRecord.getChangedData();
NOTE2: The fields focus may be lost in user interface in order to determine the edits.

getEditedRecords(foundset)

Returns an array of edited records with outstanding (unsaved) data.
NOTE: To return a dataset of outstanding (unsaved) edited data for each record, see JSRecord.getChangedData();
NOTE2: The fields focus may be lost in user interface in order to determine the edits.

getNextSequence(dataSource, columnName)

Gets the next sequence for a column which has a sequence defined in its column dataprovider properties.
NOTE: For more infomation on configuring the sequence for a column, see the section Auto enter options for a column from the Dataproviders chapter in the Servoy Developer User's Guide.

The datasource that points to the table which has the column with the sequence,
or the name of the server where the table can be found. If the name of the server
is specified, then a second optional parameter specifying the name of the table
must be used. If the datasource is specified, then the name of the table is not needed
as the second argument.

getSQL(foundsetOrQBSelect, includeFilters)

Returns the internal SQL which defines the specified (related)foundset.
Optionally, the foundset and table filter params can be excluded in the sql (includeFilters=false).
Make sure to set the applicable filters when the sql is used in a loadRecords() call.
When the founset is in find mode, the find conditions are included in the resulting query.

getSQLParameters(foundsetOrQBSelect, includeFilters)

Returns the internal SQL parameters, as an array, that are used to define the specified (related)foundset.
When the founset is in find mode, the arguments for the find conditions are included in the result.

getServerNames()

Returns an array with all the server names used in the solution.
NOTE: For more detail on named server connections, see the chapter on Database Connections, beginning with the Introduction to database connections in the Servoy Developer User's Guide.

//return the total number of rows in a table.
var count = databaseManager.getTableCount(foundset);

getTableFilterParams(serverName)

Returns a two dimensional array object containing the table filter information currently applied to the servers tables.
For column-based table filters, a row of 5 fields per filter are returned.
The "columns" of a row from this array are: tablename, dataprovider, operator, value, filtername
For query-based filters, a row of 2 fields per filter are returned.
The "columns" of a row from this array are: query, filtername

getTableFilterParams(serverName, filterName)

Returns a two dimensional array object containing the table filter information currently applied to the servers tables.
For column-based table filters, a row of 5 fields per filter are returned.
The "columns" of a row from this array are: tablename, dataprovider, operator, value, filtername
For query-based filters, a row of 2 fields per filter are returned.
The "columns" of a row from this array are: query, filtername

getViewFoundSet(name, query)

Returns a foundset object for a specified query.
This just creates one without keeping any reference to it, you have to
use registerViewFoundSet(foundset) for registering it in Servoy for use in forms.
ViewFoundSets are different then normal foundsets because they have a lot less methods, stuff like newRecord/deleteRecord don't work.
If you query the pk with the columns that you display for the main or join tables then those columns can be updated and through ViewFoundSet#save(ViewRecord) they can be saved.
If there are changes in ViewRecords of this ViewFoundSet then databroadcast configurations that need to load new data won't do the query right away (only after the save)
Also loading more (the next chunksize) will not be done. This is because the ViewRecord on an index can be completely changed. We can't track those.
Also databroadcast can be enabled by calling one of the ViewFoundSet#enableDatabroadcastFor(QBTableClause) to listen for that specific table (main or joins).
Flags can be used to control what exactly should be monitored, some don't cost a lot of overhead others have to do a full re-query to see the changes.

/** @type {ViewFoundSet<view:myname>} */
var vfs = databaseManager.getViewFoundSet('myname', query)
// register now this view foundset to the system so they can be picked up by forms if a form has the view datasource.
databaseMananger.registerViewFoundSet(vfs);

hasRecordChanges(foundset)

Returns true if the specified foundset, on a specific index or in any of its records, or the specified record has changes.
NOTE: The fields focus may be lost in user interface in order to determine the edits.

hasRecordChanges(foundset, index)

Returns true if the specified foundset, on a specific index or in any of its records, or the specified record has changes.
NOTE: The fields focus may be lost in user interface in order to determine the edits.

hasTransaction()

mergeRecords(sourceRecord, combinedDestinationRecord)

Merge records from the same foundset, updates entire datamodel (via foreign type on columns) with destination
record pk, deletes source record. Do use a transaction!
This function is very handy in situations where duplicate data exists. It allows you to merge the two records
and move all related records in one go. Say the source_record is "Ikea" and the combined_destination_record is "IKEA", the
"Ikea" record is deleted and all records related to it (think of contacts and orders, for instance) will be related
to the "IKEA" record.
The function takes an optional array of column names. If provided, the data in the named columns will be copied
from source_record to combined_destination_record.
Note that it is essential for both records to originate from the same foundset, as shown in the sample code.

mergeRecords(sourceRecord, combinedDestinationRecord, columnNames)

Merge records from the same foundset, updates entire datamodel (via foreign type on columns) with destination
record pk, deletes source record. Do use a transaction!
This function is very handy in situations where duplicate data exists. It allows you to merge the two records
and move all related records in one go. Say the source_record is "Ikea" and the combined_destination_record is "IKEA", the
"Ikea" record is deleted and all records related to it (think of contacts and orders, for instance) will be related
to the "IKEA" record.
The function takes an optional array of column names. If provided, the data in the named columns will be copied
from source_record to combined_destination_record.
Note that it is essential for both records to originate from the same foundset, as shown in the sample code.

recalculate(foundsetOrRecord)

Can be used to recalculate a specified record or all rows in the specified foundset.
May be necessary when data is changed from outside of servoy, or when there is data changed inside servoy
but records with calculations depending on that data where not loaded so not updated and you need to update
the stored calculation values because you are depending on that with queries or aggregates.

// recalculate one record from a foundset.
databaseManager.recalculate(foundset.getRecord(1));
// recalculate all records from the foundset.
// please use with care, this can be expensive!
//databaseManager.recalculate(foundset);

refreshRecordFromDatabase(foundset, index)

Flushes the client data cache and requeries the data for a record (based on the record index) in a foundset or all records in the foundset.
Used where a program external to Servoy has modified the database record.
Record index of -1 will refresh all records in the foundset and 0 the selected record.

//refresh the second record from the foundset.
databaseManager.refreshRecordFromDatabase(foundset,2)
//flushes all records in the related foundset (-1 is or can be an expensive operation)
databaseManager.refreshRecordFromDatabase(order_to_orderdetails,-1);

registerViewFoundSet(foundset)

Registers the given ViewFoundSet to the system so it is picked up by forms that have this datasource assigned.
The forms foundset will then have a much more limited API, so a lot of stuff can't be done on it like newRecord() or deleteRecords()
Also records can be updated in memory, so they are not full read-only, but the developer is responsible for saving these changes to a persisted store.
If the solution doesn't need this ViewFoundSet anymore please use unregisterViewFoundSset(datasource), because otherwise this
register call will keep/hold on to this foundset in memory (for that datasource) forever.

revertEditedRecords()

Reverts outstanding (not saved) in memory changes from edited records.
Can specify a record or foundset as parameter to rollback.
Best used in combination with the function databaseManager.setAutoSave()
This does not include deletes, they do not honor the autosafe false flag so they cant be rollbacked by this call.

Supported Clients

SmartClient,WebClient,NGClient

Sample

//Set autosave, if false then no saves will happen by the ui (not including deletes!). Until you call saveData or setAutoSave(true)
//reverts in mem the records that were edited and not yet saved. Best used in combination with autosave false.
databaseManager.setAutoSave(false)
//Now let users input data
//On save or cancel, when data has been entered:
if (cancel) databaseManager.revertEditedRecords()
//databaseManager.revertEditedRecords(foundset); // rollback all records from foundset
//databaseManager.revertEditedRecords(foundset.getSelectedRecord()); // rollback only one record
databaseManager.setAutoSave(true)

revertEditedRecords(foundset)

Reverts outstanding (not saved) in memory changes from edited records.
Can specify a record or foundset as parameter to rollback.
Best used in combination with the function databaseManager.setAutoSave()
This does not include deletes, they do not honor the autosafe false flag so they cant be rollbacked by this call.

//Set autosave, if false then no saves will happen by the ui (not including deletes!). Until you call saveData or setAutoSave(true)
//reverts in mem the records that were edited and not yet saved. Best used in combination with autosave false.
databaseManager.setAutoSave(false)
//Now let users input data
//On save or cancel, when data has been entered:
if (cancel) databaseManager.revertEditedRecords()
//databaseManager.revertEditedRecords(foundset); // rollback all records from foundset
//databaseManager.revertEditedRecords(foundset.getSelectedRecord()); // rollback only one record
databaseManager.setAutoSave(true)

rollbackTransaction()

Rollback a transaction started by databaseManager.startTransaction().
Note that when autosave is false, revertEditedRecords() will not handle deleted records, while rollbackTransaction() does.
Also, rollbackEditedRecords() is called before rolling back the transaction see rollbackTransaction(boolean) to controll that behavior
and saved records within the transactions are restored to the database values, so user input is lost, to control this see rollbackTransaction(boolean,boolean)

Supported Clients

SmartClient,WebClient,NGClient

Sample

// starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
}

rollbackTransaction(rollbackEdited)

Rollback a transaction started by databaseManager.startTransaction().
Note that when autosave is false, revertEditedRecords() will not handle deleted records, while rollbackTransaction() does.
Also, saved records within the transactions are restored to the database values, so user input is lost, to controll this see rollbackTransaction(boolean,boolean)

// starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
}

rollbackTransaction(rollbackEdited, revertSavedRecords)

Rollback a transaction started by databaseManager.startTransaction().
Note that when autosave is false, revertEditedRecords() will not handle deleted records, while rollbackTransaction() does.

if false then all records in the transaction do keep the user input and are back in the edited records list.
Note that if the pks of such a record are no longer used by it's foundset (find/search or load by query or ...) it will just be rolled-back as
it can't be put in editing records list.

Supported Clients

SmartClient,WebClient,NGClient

Sample

// starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
}

saveData()

Saves all outstanding (unsaved) data and exits the current record.
Optionally, by specifying a record or foundset, can save a single record or all records from foundset instead of all the data.
Since Servoy 8.3 saveData with null parameter does not call saveData() as fallback, it just returns false.
NOTE: The fields focus may be lost in user interface in order to determine the edits.
SaveData called from table events (like afterRecordInsert) is only partially supported depeding on how first saveData (that triggers the event) is called.
If first saveData is called with no arguments, all saveData from table events are returning immediatelly with true value and records will be saved as part of first save.
If first saveData is called with record(s) as arguments, saveData from table event will try to save record(s) from arguments that are different than those in first call.
SaveData with no arguments inside table events will always return true without saving anything.

saveData(foundset)

Saves all outstanding (unsaved) data and exits the current record.
Optionally, by specifying a record or foundset, can save a single record or all records from foundset instead of all the data.
Since Servoy 8.3 saveData with null parameter does not call saveData() as fallback, it just returns false.
NOTE: The fields focus may be lost in user interface in order to determine the edits.
SaveData called from table events (like afterRecordInsert) is only partially supported depeding on how first saveData (that triggers the event) is called.
If first saveData is called with no arguments, all saveData from table events are returning immediatelly with true value and records will be saved as part of first save.
If first saveData is called with record(s) as arguments, saveData from table event will try to save record(s) from arguments that are different than those in first call.
SaveData with no arguments inside table events will always return true without saving anything.

saveData(record)

Saves all outstanding (unsaved) data and exits the current record.
Optionally, by specifying a record or foundset, can save a single record or all records from foundset instead of all the data.
Since Servoy 8.3 saveData with null parameter does not call saveData() as fallback, it just returns false.
NOTE: The fields focus may be lost in user interface in order to determine the edits.
SaveData called from table events (like afterRecordInsert) is only partially supported depeding on how first saveData (that triggers the event) is called.
If first saveData is called with no arguments, all saveData from table events are returning immediatelly with true value and records will be saved as part of first save.
If first saveData is called with record(s) as arguments, saveData from table event will try to save record(s) from arguments that are different than those in first call.
SaveData with no arguments inside table events will always return true without saving anything.

setAutoSave(autoSave)

Set autosave, if false then no saves will happen by the ui (not including deletes!).
Until you call databaseManager.saveData() or setAutoSave(true)
If you also want to be able to rollback deletes then you have to use databaseManager.startTransaction().
Because even if autosave is false deletes of records will be done.

//Rollbacks in mem the records that were edited and not yet saved. Best used in combination with autosave false.
databaseManager.setAutoSave(false)
//Now let users input data
//On save or cancel, when data has been entered:
if (cancel) databaseManager.rollbackEditedRecords()
databaseManager.setAutoSave(true)

setCreateEmptyFormFoundsets()

Turnoff the initial form foundset record loading, set this in the solution open method.
Simular to calling foundset.clear() in the form's onload event.
NOTE: When the foundset record loading is turned off, controller.find or controller.loadAllRecords must be called to display the records

Supported Clients

SmartClient,WebClient,NGClient

Sample

//this has to be called in the solution open method
databaseManager.setCreateEmptyFormFoundsets()

startTransaction()

Start a database transaction.
If you want to avoid round trips to the server or avoid the posibility of blocking other clients
because of your pending changes, you can use databaseManager.setAutoSave(false/true) and databaseManager.rollbackEditedRecords().
startTransaction, commit/rollbackTransacton() does support rollbacking of record deletes which autoSave = false doesnt support.

Supported Clients

SmartClient,WebClient,NGClient

Sample

// starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
}

switchServer(sourceName, destinationName)

Switches a named server to another named server with the same datamodel (recommended to be used in an onOpen method for a solution).
return true if successful.
Note that this only works if source and destination server are of the same database type.

//dynamically changes a server for the entire solution, destination database server must contain the same tables/columns!
//will fail if there is a lock, transaction , if repository_server is used or if destination server is invalid
//in the solution keep using the sourceName every where to reference the server!
var success = databaseManager.switchServer('crm', 'crm1')

unegisterViewFoundSet(datasource)

Unregisters a ViewFoundSet based on the datasource. (ViewFoundSet.getDataSource())
This cleans up the state (the foundset and its loaded records) from the system. So call this when you don't need it anymore
and - for example - it can be recreated when a user returns to this form.
If a form is still loaded in memory having this foundset then that foundset will be kept there. (until that form is also unloaded)