DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR
Return Types
{column:width=80px|padding=0px}{column}{column}{column}
Property Summary
nullColumnValidatorEnabled
Enable/disable the default null validator for non null columns, makes it possible todo the checks later on when saving, when for example autosave is disabled.
{column:width=80px|padding=0px}{column}{column}{column}
Method Summary
acquireLock(foundset, recordIndex)
Request lock(s) for a foundset, can be a normal or related foundset.
acquireLock(foundset, recordIndex, lockName)
Request lock(s) for a foundset, can be a normal or related foundset.
addTableFilterParam(datasource, dataprovider, operator, value)
Adds a filter to all the foundsets based on a table.
addTableFilterParam(datasource, dataprovider, operator, value, filterName)
Adds a filter to all the foundsets based on a table.
addTableFilterParam(serverName, tableName, dataprovider, operator, value)
Adds a filter to all the foundsets based on a table.
addTableFilterParam(serverName, tableName, dataprovider, operator, value, filterName)
Adds a filter to all the foundsets based on a table.
void
addTrackingInfo(columnName, value)
Add tracking info used in the log table.
commitTransaction()
Returns true if a transaction is committed; rollback if commit fails.
commitTransaction(saveFirst)
Returns true if a transaction is committed; rollback if commit fails.
commitTransaction(saveFirst, revertSavedRecords)
Returns true if a transaction is committed; rollback if commit fails.
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.
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.
convertToDataSet(foundset)
Converts the argument to a JSDataSet, possible use in controller.
convertToDataSet(foundset, dataproviderNames)
Converts the argument to a JSDataSet, possible use in controller.
convertToDataSet(values)
Converts the argument to a JSDataSet, possible use in controller.
convertToDataSet(values, dataproviderNames)
Converts the argument to a JSDataSet, possible use in controller.
convertToDataSet(ids)
Converts the argument to a JSDataSet, possible use in controller.
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).
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).
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).
createDataSourceByQuery(name, query, max_returned_rows)
Performs a query and saves the result in a datasource.
createDataSourceByQuery(name, query, max_returned_rows, types)
Performs a query and saves the result in a datasource.
createDataSourceByQuery(name, server_name, sql_query, arguments, max_returned_rows)
Performs a sql query on the specified server, saves the the result in a datasource.
createDataSourceByQuery(name, server_name, sql_query, arguments, max_returned_rows, types)
Performs a sql query on the specified server, saves the the result in a datasource.
createEmptyDataSet()
Returns an empty dataset object.
createEmptyDataSet(rowCount, columnCount)
Returns an empty dataset object.
createEmptyDataSet(rowCount, columnNames)
Returns an empty dataset object.
createSelect(dataSource)
Create a QueryBuilder object for a datasource.
dataSourceExists(datasource)
Check wether a data source exists.
getAutoSave()
Returns true or false if autosave is enabled or disabled.
String[]
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.
getDataSetByQuery(server_name, sql_query, arguments, max_returned_rows)
Performs a sql query on the specified server, returns the result in a dataset.
getDataSource(serverName, tableName)
Returns the datasource corresponding to the given server/table.
getDataSourceServerName(dataSource)
Returns the server name from the datasource, or null if not a database datasource.
getDataSourceTableName(dataSource)
Returns the table name from the datasource, or null if not a database datasource.
getDatabaseProductName(serverName)
Returns the database product name as supplied by the driver for a server.
JSRecord[]
getEditedRecords()
Returns an array of edited records with outstanding (unsaved) data.
JSRecord[]
getEditedRecords(foundset)
Returns an array of edited records with outstanding (unsaved) data.
JSRecord[]
getFailedRecords()
Returns an array of records that fail after a save.
JSRecord[]
getFailedRecords(foundset)
Returns an array of records that fail after a save.
getFoundSet(query)
Returns a foundset object for a specified pk query.
getFoundSet(dataSource)
Returns a foundset object for a specified datasource or server and tablename.
getFoundSet(serverName, tableName)
Returns a foundset object for a specified datasource or server and tablename.
getFoundSetCount(foundset)
Returns the total number of records in a foundset.
getFoundSetUpdater(foundset)
Returns a JSFoundsetUpdater object that can be used to update all or a specific number of rows in the specified foundset.
getNextSequence(dataSource, columnName)
Gets the next sequence for a column which has a sequence defined in its column dataprovider properties.
Object[]
getSQLParameters(foundset)
Returns the internal SQL parameters, as an array, that are used to define the specified (related)foundset.
Object[]
getSQLParameters(foundset, includeFilters)
Returns the internal SQL parameters, as an array, that are used to define the specified (related)foundset.
String[]
getServerNames()
Returns an array with all the server names used in the solution.
getTableCount(dataSource)
Returns the total number of records(rows) in a table.
Object[][]
getTableFilterParams(serverName)
Returns a two dimensional array object containing the table filter information currently applied to the servers tables.
Object[][]
getTableFilterParams(serverName, filterName)
Returns a two dimensional array object containing the table filter information currently applied to the servers tables.
String[]
getTableNames(serverName)
Returns an array of all table names for a specified server.
String[]
getViewNames(serverName)
Returns an array of all view names for a specified server.
hasNewRecords(foundset)
Returns true if the argument (foundSet / record) has at least one row that was not yet saved in the database.
hasNewRecords(foundset, index)
Returns true if the argument (foundSet / record) has at least one row that was not yet saved in the database.
hasRecordChanges(foundset)
Returns true if the specified foundset, on a specific index or in any of its records, or the specified record has changes.
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.
hasRecords(foundset)
Returns true if the (related)foundset exists and has records.
hasRecords(record, relationString)
Returns true if the (related)foundset exists and has records.
hasTransaction()
Returns true if there is an transaction active for this client.
mergeRecords(sourceRecord, combinedDestinationRecord)
Merge records from the same foundset, updates entire datamodel (via foreign type on columns) with destination
record pk, deletes source record.
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.
void
recalculate(foundsetOrRecord)
Can be used to recalculate a specified record or all rows in the specified 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.
releaseAllLocks()
Release all current locks the client has (optionally limited to named locks).
releaseAllLocks(lockName)
Release all current locks the client has (optionally limited to named locks).
removeTableFilterParam(serverName, filterName)
Removes a previously defined table filter.
void
revertEditedRecords()
Reverts outstanding (not saved) in memory changes from edited records.
void
revertEditedRecords(foundset)
Reverts outstanding (not saved) in memory changes from edited records.
void
rollbackTransaction()
Rollback a transaction started by databaseManager.
void
rollbackTransaction(rollbackEdited)
Rollback a transaction started by databaseManager.
void
rollbackTransaction(rollbackEdited, revertSavedRecords)
Rollback a transaction started by databaseManager.
setAutoSave(autoSave)
Set autosave, if false then no saves will happen by the ui (not including deletes!).
void
setCreateEmptyFormFoundsets()
Turnoff the initial form foundset record loading, set this in the solution open method.
void
startTransaction()
Start a database transaction.
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).
{column:width=100%|padding=0px}{column}
Property Details
Sample
databaseManager.nullColumnValidatorEnabled = false;//disable //test if enabled if(databaseManager.nullColumnValidatorEnabled) application.output('null validation enabled')
{column:width=100%|padding=0px}{column}
Method Details
acquireLock
(foundset, recordIndex)
Parameters
{JSFoundSet} foundset – The JSFoundset to get the lock for
{Number} recordIndex – The record index which should be locked.
Sample
//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)
Parameters
{JSFoundSet} foundset – The JSFoundset to get the lock for
{Number} recordIndex – The record index which should be locked.
{String} lockName – The name of the lock.
Sample
//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
(datasource, dataprovider, operator, value)
Parameters
{String} datasource – The datasource
{String} dataprovider – A specified dataprovider column name.
{String} operator – One of "=, <, >, >=, <=, !=, LIKE, or IN" optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null).
{Object} value – The specified filter value.
Returns
Boolean – true if the tablefilter could be applied.
Sample
// 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') //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])
addTableFilterParam
(datasource, dataprovider, operator, value, filterName)
Parameters
{String} datasource – The datasource
{String} dataprovider – A specified dataprovider column name.
{String} operator – One of "=, <, >, >=, <=, !=, LIKE, or IN" optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null).
{Object} value – The specified filter value.
{String} filterName – The specified name of the database table filter.
Returns
Boolean – true if the tablefilter could be applied.
Sample
// 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') //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])
addTableFilterParam
(serverName, tableName, dataprovider, operator, value)
Parameters
{String} serverName – The name of the database server connection for the specified table name.
{String} tableName – The name of the specified table.
{String} dataprovider – A specified dataprovider column name.
{String} operator – One of "=, <, >, >=, <=, !=, LIKE, or IN" optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null).
{Object} value – The specified filter value.
Returns
Boolean – true if the tablefilter could be applied.
Sample
// 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') //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])
addTableFilterParam
(serverName, tableName, dataprovider, operator, value, filterName)
Parameters
{String} serverName – The name of the database server connection for the specified table name.
{String} tableName – The name of the specified table.
{String} dataprovider – A specified dataprovider column name.
{String} operator – One of "=, <, >, >=, <=, !=, LIKE, or IN" optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null).
{Object} value – The specified filter value.
{String} filterName – The specified name of the database table filter.
Returns
Boolean – true if the tablefilter could be applied.
Sample
// 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') //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])
void
addTrackingInfo
(columnName, value)
Returns
void
Sample
databaseManager.addTrackingInfo('log_column_name', 'trackingInfo')
commitTransaction
()
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(); }
commitTransaction
(saveFirst)
Parameters
{Boolean} saveFirst – save edited records to the database first (default true)
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(); }
commitTransaction
(saveFirst, revertSavedRecords)
Parameters
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(); }
convertFoundSet
(foundset, related)
Parameters
{JSFoundSet} foundset – The JSFoundset to convert.
{JSFoundSet} related – can be a one-to-many relation object or the name of a one-to-many relation
Sample
// 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)
Parameters
{JSFoundSet} foundset – The JSFoundset to convert.
{String} related – the name of a one-to-many relation
Sample
// 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)
Parameters
{JSFoundSet} foundset – The foundset to be converted.
Sample
// converts a foundset pks to a dataset var dataset = databaseManager.convertToDataSet(foundset); // converts a foundset to a dataset //var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']); // converts an object array to a dataset //var dataset = databaseManager.convertToDataSet(files,['name','path']); // converts an array to a dataset //var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6)); // converts an string list to a dataset //var dataset = databaseManager.convertToDataSet('4,5,6');
convertToDataSet
(foundset, dataproviderNames)
Parameters
{JSFoundSet} foundset – The foundset to be converted.
{String[]} dataproviderNames – Array with column names.
Sample
// converts a foundset pks to a dataset var dataset = databaseManager.convertToDataSet(foundset); // converts a foundset to a dataset //var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']); // converts an object array to a dataset //var dataset = databaseManager.convertToDataSet(files,['name','path']); // converts an array to a dataset //var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6)); // converts an string list to a dataset //var dataset = databaseManager.convertToDataSet('4,5,6');
convertToDataSet
(values)
Sample
// converts a foundset pks to a dataset var dataset = databaseManager.convertToDataSet(foundset); // converts a foundset to a dataset //var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']); // converts an object array to a dataset //var dataset = databaseManager.convertToDataSet(files,['name','path']); // converts an array to a dataset //var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6)); // converts an string list to a dataset //var dataset = databaseManager.convertToDataSet('4,5,6');
convertToDataSet
(values, dataproviderNames)
Sample
// converts a foundset pks to a dataset var dataset = databaseManager.convertToDataSet(foundset); // converts a foundset to a dataset //var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']); // converts an object array to a dataset //var dataset = databaseManager.convertToDataSet(files,['name','path']); // converts an array to a dataset //var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6)); // converts an string list to a dataset //var dataset = databaseManager.convertToDataSet('4,5,6');
convertToDataSet
(ids)
Parameters
{String} ids – Concatenated values to be put into dataset.
Sample
// converts a foundset pks to a dataset var dataset = databaseManager.convertToDataSet(foundset); // converts a foundset to a dataset //var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']); // converts an object array to a dataset //var dataset = databaseManager.convertToDataSet(files,['name','path']); // converts an array to a dataset //var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6)); // converts an string list to a dataset //var dataset = databaseManager.convertToDataSet('4,5,6');
copyMatchingFields
(source, destination)
Sample
for( var i = 1 ; i <= foundset.getSize() ; i++ ) { var srcRecord = foundset.getRecord(i); var destRecord = otherfoundset.getRecord(i); if (srcRecord == null || destRecord == null) break; databaseManager.copyMatchingFields(srcRecord,destRecord,true) } //saves any outstanding changes to the dest foundset databaseManager.saveData(); //copying from a MailMessage JavaScript object //var _msg = plugins.mail.receiveMail(login, password, true, 0, null, properties); //if (_msg != null) //{ // controller.newRecord(); // var srcObject = _msg[0]; // var destRecord = foundset.getSelectedRecord(); // databaseManager.copyMatchingFields(srcObject, destRecord, true); // databaseManager.saveData(); //}
copyMatchingFields
(source, destination, overwrite)
Sample
for( var i = 1 ; i <= foundset.getSize() ; i++ ) { var srcRecord = foundset.getRecord(i); var destRecord = otherfoundset.getRecord(i); if (srcRecord == null || destRecord == null) break; databaseManager.copyMatchingFields(srcRecord,destRecord,true) } //saves any outstanding changes to the dest foundset databaseManager.saveData(); //copying from a MailMessage JavaScript object //var _msg = plugins.mail.receiveMail(login, password, true, 0, null, properties); //if (_msg != null) //{ // controller.newRecord(); // var srcObject = _msg[0]; // var destRecord = foundset.getSelectedRecord(); // databaseManager.copyMatchingFields(srcObject, destRecord, true); // databaseManager.saveData(); //}
copyMatchingFields
(source, destination, names)
Sample
for( var i = 1 ; i <= foundset.getSize() ; i++ ) { var srcRecord = foundset.getRecord(i); var destRecord = otherfoundset.getRecord(i); if (srcRecord == null || destRecord == null) break; databaseManager.copyMatchingFields(srcRecord,destRecord,true) } //saves any outstanding changes to the dest foundset databaseManager.saveData(); //copying from a MailMessage JavaScript object //var _msg = plugins.mail.receiveMail(login, password, true, 0, null, properties); //if (_msg != null) //{ // controller.newRecord(); // var srcObject = _msg[0]; // var destRecord = foundset.getSelectedRecord(); // databaseManager.copyMatchingFields(srcObject, destRecord, true); // databaseManager.saveData(); //}
createDataSourceByQuery
(name, query, max_returned_rows)
Returns
String – datasource containing the results of the query or null if the parameters are wrong.
Sample
// select customer data for order 1234 /** @type {QBSelect<db:/example_data/customers>} */ var q = databaseManager.createSelect("db:/example_data/customers"); q.result.add(q.columns.address).add(q.columns.city).add(q.columns.country); q.where.add(q.joins.customers_to_orders.columns.orderid.eq(1234)); var uri = databaseManager.createDataSourceByQuery('mydata', q, 999); //var uri = databaseManager.createDataSourceByQuery('mydata', q, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT]); // the uri can be used to create a form using solution model var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600); myForm.newTextField('city', 140, 20, 140,20); // the uri can be used to acces a foundset directly var fs = databaseManager.getFoundSet(uri); fs.loadAllRecords();
createDataSourceByQuery
(name, query, max_returned_rows, types)
Returns
String – datasource containing the results of the query or null if the parameters are wrong.
Sample
// select customer data for order 1234 /** @type {QBSelect<db:/example_data/customers>} */ var q = databaseManager.createSelect("db:/example_data/customers"); q.result.add(q.columns.address).add(q.columns.city).add(q.columns.country); q.where.add(q.joins.customers_to_orders.columns.orderid.eq(1234)); var uri = databaseManager.createDataSourceByQuery('mydata', q, 999); //var uri = databaseManager.createDataSourceByQuery('mydata', q, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT]); // the uri can be used to create a form using solution model var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600); myForm.newTextField('city', 140, 20, 140,20); // the uri can be used to acces a foundset directly var fs = databaseManager.getFoundSet(uri); fs.loadAllRecords();
createDataSourceByQuery
(name, server_name, sql_query, arguments, max_returned_rows)
Parameters
{String} name – data source name
{String} server_name – The name of the server where the query should be executed.
{String} sql_query – The custom sql.
{Object[]} arguments – Specified arguments or null if there are no arguments.
{Number} max_returned_rows – The maximum number of rows returned by the query.
Returns
String – datasource containing the results of the query or null if the parameters are wrong.
Sample
var query = 'select address, city, country from customers'; var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999); //var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT]); // the uri can be used to create a form using solution model var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600) myForm.newTextField('city', 140, 20, 140,20) // the uri can be used to acces a foundset directly var fs = databaseManager.getFoundSet(uri) fs.loadAllRecords();
createDataSourceByQuery
(name, server_name, sql_query, arguments, max_returned_rows, types)
Parameters
{String} name – data source name
{String} server_name – The name of the server where the query should be executed.
{String} sql_query – The custom sql.
{Object[]} arguments – Specified arguments or null if there are no arguments.
{Number} max_returned_rows – The maximum number of rows returned by the query.
{Number[]} types – The column types
Returns
String – datasource containing the results of the query or null if the parameters are wrong.
Sample
var query = 'select address, city, country from customers'; var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999); //var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT]); // the uri can be used to create a form using solution model var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600) myForm.newTextField('city', 140, 20, 140,20) // the uri can be used to acces a foundset directly var fs = databaseManager.getFoundSet(uri) fs.loadAllRecords();
createEmptyDataSet
()
Returns
JSDataSet – An empty JSDataSet with the initial sizes.
Sample
// gets an empty dataset with a specifed row and column count var dataset = databaseManager.createEmptyDataSet(10,10) // gets an empty dataset with a specifed row count and column array var dataset2 = databaseManager.createEmptyDataSet(10,new Array ('a','b','c','d'))
createEmptyDataSet
(rowCount, columnCount)
Returns
JSDataSet – An empty JSDataSet with the initial sizes.
Sample
// gets an empty dataset with a specifed row and column count var dataset = databaseManager.createEmptyDataSet(10,10) // gets an empty dataset with a specifed row count and column array var dataset2 = databaseManager.createEmptyDataSet(10,new Array ('a','b','c','d'))
createEmptyDataSet
(rowCount, columnNames)
Returns
JSDataSet – An empty JSDataSet with the initial sizes.
Sample
// gets an empty dataset with a specifed row and column count var dataset = databaseManager.createEmptyDataSet(10,10) // gets an empty dataset with a specifed row count and column array var dataset2 = databaseManager.createEmptyDataSet(10,new Array ('a','b','c','d'))
createSelect
(dataSource)
Parameters
{String} dataSource – The data source to build a query for.
Sample
/** @type {QBSelect<db:/example_data/book_nodes>} */ var q = databaseManager.createSelect('db:/example_data/book_nodes') q.result.addPk() q.where.add(q.columns.label_text.not.isin(null)) databaseManager.getFoundSet('db:/example_data/book_nodes').loadRecords(q)
dataSourceExists
(datasource)
Parameters
datasource
Sample
if (!databaseManager.dataSourceExists(dataSource)) { // does not exist }
getAutoSave
()
Sample
//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)
String[]
getDataModelClonesFrom
(serverName)
Sample
var serverNames = databaseManager.getDataModelClonesFrom('myServerName');
getDataSetByQuery
(query, max_returned_rows)
Returns
JSDataSet – The JSDataSet containing the results of the query.
Sample
// use the query froma foundset and add a condition /** @type {QBSelect<db:/example_data/orders>} */ var q = foundset.getQuery() q.where.add(q.joins.orders_to_order_details.columns.discount.eq(2)) var maxReturnedRows = 10;//useful to limit number of rows var ds = databaseManager.getDataSetByQuery(q, maxReturnedRows); // query: select PK from example.book_nodes where parent = 111 and(note_date is null or note_date > now) /** @type {QBSelect<db:/example_data/book_nodes>} */ var query = databaseManager.createSelect('db:/example_data/book_nodes').result.addPk().root query.where.add(query.columns.parent_id.eq(111)) .add(query.or .add(query.columns.note_date.isNull) .add(query.columns.note_date.gt(new Date()))) databaseManager.getDataSetByQuery(q, max_returned_rows)
getDataSetByQuery
(server_name, sql_query, arguments, max_returned_rows)
Parameters
Returns
JSDataSet – The JSDataSet containing the results of the query.
Sample
//finds duplicate records in a specified foundset var vQuery =" SELECT companiesid from companies where company_name IN (SELECT company_name from companies group bycompany_name having count(company_name)>1 )"; var vDataset = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()), vQuery, null, 1000); controller.loadRecords(vDataset); var maxReturnedRows = 10;//useful to limit number of rows var query = 'select c1,c2,c3 from test_table where start_date = ?';//do not use '.' or special chars in names or aliases if you want to access data by name var args = new Array(); args[0] = order_date //or new Date() var dataset = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()), query, args, maxReturnedRows); // place in label: // elements.myLabel.text = '<html>'+dataset.getAsHTML()+'</html>'; //example to calc a strange total global_total = 0; for( var i = 1 ; i <= dataset.getMaxRowIndex() ; i++ ) { dataset.rowIndex = i; global_total = global_total + dataset.c1 + dataset.getValue(i,3); } //example to assign to dataprovider //employee_salary = dataset.getValue(row,column)
getDataSource
(serverName, tableName)
Sample
var datasource = databaseManager.getDataSource('example_data', 'categories');
getDataSourceServerName
(dataSource)
Parameters
{String} dataSource – The datasource string to get the server name from.
Sample
var servername = databaseManager.getDataSourceServerName(datasource);
getDataSourceTableName
(dataSource)
Parameters
{String} dataSource – The datasource string to get the tablename from.
Sample
var tablename = databaseManager.getDataSourceTableName(datasource);
getDatabaseProductName
(serverName)
Parameters
{String} serverName – The specified name of the database server connection.
Sample
var databaseProductName = databaseManager.getDatabaseProductName(servername)
JSRecord[]
getEditedRecords
()
Returns
JSRecord[] – Array of outstanding/unsaved JSRecords.
Sample
//This method can be used to loop through all outstanding changes, //the application.output line contains all the changed data, their tablename and primary key var editr = databaseManager.getEditedRecords() for (x=0;x<editr.length;x++) { var ds = editr[x].getChangedData(); var jstable = databaseManager.getTable(editr[x]); var tableSQLName = jstable.getSQLName(); var pkrec = jstable.getRowIdentifierColumnNames().join(','); var pkvals = new Array(); for (var j = 0; j < jstable.getRowIdentifierColumnNames().length; j++) { pkvals[j] = editr[x][jstable.getRowIdentifierColumnNames()[j]]; } application.output('Table: '+tableSQLName +', PKs: '+ pkvals.join(',') +' ('+pkrec +')'); // Get a dataset with outstanding changes on a record for( var i = 1 ; i <= ds.getMaxRowIndex() ; i++ ) { application.output('Column: '+ ds.getValue(i,1) +', oldValue: '+ ds.getValue(i,2) +', newValue: '+ ds.getValue(i,3)); } } //in most cases you will want to set autoSave back on now databaseManager.setAutoSave(true);
JSRecord[]
getEditedRecords
(foundset)
Parameters
{JSFoundSet} foundset – return edited records in the foundset only.
Returns
JSRecord[] – Array of outstanding/unsaved JSRecords.
Sample
//This method can be used to loop through all outstanding changes in a foundset, //the application.output line contains all the changed data, their tablename and primary key var editr = databaseManager.getEditedRecords(foundset) for (x=0;x<editr.length;x++) { var ds = editr[x].getChangedData(); var jstable = databaseManager.getTable(editr[x]); var tableSQLName = jstable.getSQLName(); var pkrec = jstable.getRowIdentifierColumnNames().join(','); var pkvals = new Array(); for (var j = 0; j < jstable.getRowIdentifierColumnNames().length; j++) { pkvals[j] = editr[x][jstable.getRowIdentifierColumnNames()[j]]; } application.output('Table: '+tableSQLName +', PKs: '+ pkvals.join(',') +' ('+pkrec +')'); // Get a dataset with outstanding changes on a record for( var i = 1 ; i <= ds.getMaxRowIndex() ; i++ ) { application.output('Column: '+ ds.getValue(i,1) +', oldValue: '+ ds.getValue(i,2) +', newValue: '+ ds.getValue(i,3)); } } databaseManager.saveData(foundset);//save all records from foundset
JSRecord[]
getFailedRecords
()
Sample
var array = databaseManager.getFailedRecords() for( var i = 0 ; i < array.length ; i++ ) { var record = array[i]; application.output(record.exception); if (record.exception.getErrorCode() == ServoyException.RECORD_VALIDATION_FAILED) { // exception thrown in pre-insert/update/delete event method var thrown = record.exception.getValue() application.output("Record validation failed: "+thrown) } // find out the table of the record (similar to getEditedRecords) var jstable = databaseManager.getTable(record); var tableSQLName = jstable.getSQLName(); application.output('Table:'+tableSQLName+' in server:'+jstable.getServerName()+' failed to save.') }
JSRecord[]
getFailedRecords
(foundset)
Parameters
{JSFoundSet} foundset – return failed records in the foundset only.
Sample
var array = databaseManager.getFailedRecords(foundset) for( var i = 0 ; i < array.length ; i++ ) { var record = array[i]; application.output(record.exception); if (record.exception.getErrorCode() == ServoyException.RECORD_VALIDATION_FAILED) { // exception thrown in pre-insert/update/delete event method var thrown = record.exception.getValue() application.output("Record validation failed: "+thrown) } // find out the table of the record (similar to getEditedRecords) var jstable = databaseManager.getTable(record); var tableSQLName = jstable.getSQLName(); application.output('Table:'+tableSQLName+' in server:'+jstable.getServerName()+' failed to save.') }
getFoundSet
(query)
Parameters
{QBSelect} query – The query to get the JSFoundset for.
Sample
// type the foundset returned from the call with JSDoc, fill in the right server/tablename /** @type {JSFoundset<db:/servername/tablename>} */ var fs = databaseManager.getFoundSet(controller.getDataSource()) var ridx = fs.newRecord() var record = fs.getRecord(ridx) record.emp_name = 'John' databaseManager.saveData()
getFoundSet
(dataSource)
Parameters
{String} dataSource – The datasource to get a JSFoundset for.
Sample
// type the foundset returned from the call with JSDoc, fill in the right server/tablename /** @type {JSFoundset<db:/servername/tablename>} */ var fs = databaseManager.getFoundSet(controller.getDataSource()) var ridx = fs.newRecord() var record = fs.getRecord(ridx) record.emp_name = 'John' databaseManager.saveData()
getFoundSet
(serverName, tableName)
Sample
// type the foundset returned from the call with JSDoc, fill in the right server/tablename /** @type {JSFoundset<db:/servername/tablename>} */ var fs = databaseManager.getFoundSet(controller.getDataSource()) var ridx = fs.newRecord() var record = fs.getRecord(ridx) record.emp_name = 'John' databaseManager.saveData()
getFoundSetCount
(foundset)
Parameters
{Object} foundset – The JSFoundset to get the count for.
Sample
//return the total number of records in a foundset. databaseManager.getFoundSetCount(foundset);
getFoundSetUpdater
(foundset)
Returns
JSFoundSetUpdater – The JSFoundsetUpdater for the specified JSFoundset.
Sample
//1) update entire foundset var fsUpdater = databaseManager.getFoundSetUpdater(foundset) fsUpdater.setColumn('customer_type',1) fsUpdater.setColumn('my_flag',0) fsUpdater.performUpdate() //2) update part of foundset, for example the first 4 row (starts with selected row) var fsUpdater = databaseManager.getFoundSetUpdater(foundset) fsUpdater.setColumn('customer_type',new Array(1,2,3,4)) fsUpdater.setColumn('my_flag',new Array(1,0,1,0)) fsUpdater.performUpdate() //3) safely loop through foundset (starts with selected row) controller.setSelectedIndex(1) var count = 0 var fsUpdater = databaseManager.getFoundSetUpdater(foundset) while(fsUpdater.next()) { fsUpdater.setColumn('my_flag',count++) }
getNextSequence
(dataSource, columnName)
Parameters
{String} dataSource – 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.
{String} columnName – The name of the column that has a sequence defined in its properties.
Returns
Object – The next sequence for the column, null if there was no sequence for that column
or if there is no column with the given name.
Sample
var seqDataSource = forms.seq_table.controller.getDataSource(); var nextValue = databaseManager.getNextSequence(seqDataSource, 'seq_table_value'); application.output(nextValue); nextValue = databaseManager.getNextSequence(databaseManager.getDataSourceServerName(seqDataSource), databaseManager.getDataSourceTableName(seqDataSource), 'seq_table_value') application.output(nextValue);
getSQL
(foundset)
Parameters
{Object} foundset – The JSFoundset to get the sql for.
Returns
String – String representing the sql of the JSFoundset.
Sample
var sql = databaseManager.getSQL(foundset)
getSQL
(foundset, includeFilters)
Returns
String – String representing the sql of the JSFoundset.
Sample
var sql = databaseManager.getSQL(foundset)
Object[]
getSQLParameters
(foundset)
Parameters
{Object} foundset – The JSFoundset to get the sql parameters for.
Sample
var sqlParameterArray = databaseManager.getSQLParameters(foundset,false)
Object[]
getSQLParameters
(foundset, includeFilters)
Sample
var sqlParameterArray = databaseManager.getSQLParameters(foundset,false)
String[]
getServerNames
()
Sample
var array = databaseManager.getServerNames()
getTable
(foundset)
Parameters
{JSFoundSet} foundset – The foundset where the JSTable can be get from.
Sample
var jstable = databaseManager.getTable(controller.getDataSource()); //var jstable = databaseManager.getTable(foundset); //var jstable = databaseManager.getTable(record); //var jstable = databaseManager.getTable(datasource); var tableSQLName = jstable.getSQLName(); var columnNamesArray = jstable.getColumnNames(); var firstColumnName = columnNamesArray[0]; var jscolumn = jstable.getColumn(firstColumnName); var columnLength = jscolumn.getLength(); var columnType = jscolumn.getTypeAsString(); var columnSQLName = jscolumn.getSQLName(); var isPrimaryKey = jscolumn.isRowIdentifier();
getTable
(record)
Parameters
{JSRecord} record – The record where the table can be get from.
Sample
var jstable = databaseManager.getTable(controller.getDataSource()); //var jstable = databaseManager.getTable(foundset); //var jstable = databaseManager.getTable(record); //var jstable = databaseManager.getTable(datasource); var tableSQLName = jstable.getSQLName(); var columnNamesArray = jstable.getColumnNames(); var firstColumnName = columnNamesArray[0]; var jscolumn = jstable.getColumn(firstColumnName); var columnLength = jscolumn.getLength(); var columnType = jscolumn.getTypeAsString(); var columnSQLName = jscolumn.getSQLName(); var isPrimaryKey = jscolumn.isRowIdentifier();
getTable
(dataSource)
Parameters
{String} dataSource – The datasource where the table can be get from.
Sample
var jstable = databaseManager.getTable(controller.getDataSource()); //var jstable = databaseManager.getTable(foundset); //var jstable = databaseManager.getTable(record); //var jstable = databaseManager.getTable(datasource); var tableSQLName = jstable.getSQLName(); var columnNamesArray = jstable.getColumnNames(); var firstColumnName = columnNamesArray[0]; var jscolumn = jstable.getColumn(firstColumnName); var columnLength = jscolumn.getLength(); var columnType = jscolumn.getTypeAsString(); var columnSQLName = jscolumn.getSQLName(); var isPrimaryKey = jscolumn.isRowIdentifier();
getTable
(serverName, tableName)
Sample
var jstable = databaseManager.getTable(controller.getDataSource()); //var jstable = databaseManager.getTable(foundset); //var jstable = databaseManager.getTable(record); //var jstable = databaseManager.getTable(datasource); var tableSQLName = jstable.getSQLName(); var columnNamesArray = jstable.getColumnNames(); var firstColumnName = columnNamesArray[0]; var jscolumn = jstable.getColumn(firstColumnName); var columnLength = jscolumn.getLength(); var columnType = jscolumn.getTypeAsString(); var columnSQLName = jscolumn.getSQLName(); var isPrimaryKey = jscolumn.isRowIdentifier();
getTableCount
(dataSource)
Parameters
{Object} dataSource – Data where a server table can be get from. Can be a foundset, a datasource name or a JSTable.
Sample
//return the total number of rows in a table. var count = databaseManager.getTableCount(foundset);
Object[][]
getTableFilterParams
(serverName)
Parameters
{String} serverName – The name of the database server connection.
Sample
var params = databaseManager.getTableFilterParams(databaseManager.getDataSourceServerName(controller.getDataSource())) for (var i = 0; params != null && i < params.length; i++) { application.output('Table filter on table ' + params[i][0]+ ': '+ params[i][1]+ ' '+params[i][2]+ ' '+params[i][3] +(params[i][4] == null ? ' [no name]' : ' ['+params[i][4]+']')) }
Object[][]
getTableFilterParams
(serverName, filterName)
Sample
var params = databaseManager.getTableFilterParams(databaseManager.getDataSourceServerName(controller.getDataSource())) for (var i = 0; params != null && i < params.length; i++) { application.output('Table filter on table ' + params[i][0]+ ': '+ params[i][1]+ ' '+params[i][2]+ ' '+params[i][3] +(params[i][4] == null ? ' [no name]' : ' ['+params[i][4]+']')) }
String[]
getTableNames
(serverName)
Parameters
{String} serverName – The server name to get the table names from.
Returns
String[] – An Array with the tables names of that server.
Sample
//return all the table names as array var tableNamesArray = databaseManager.getTableNames('user_data'); var firstTableName = tableNamesArray[0];
String[]
getViewNames
(serverName)
Parameters
{String} serverName – The server name to get the view names from.
Returns
String[] – An Array with the view names of that server.
Sample
//return all the view names as array var viewNamesArray = databaseManager.getViewNames('user_data'); var firstViewName = viewNamesArray[0];
hasLocks
()
Returns
Boolean – true if the current client has locks or the lock.
Sample
var hasLocks = databaseManager.hasLocks('mylock')
hasLocks
(lockName)
Returns
Boolean – true if the current client has locks or the lock.
Sample
var hasLocks = databaseManager.hasLocks('mylock')
hasNewRecords
(foundset)
Returns
Boolean – true if the JSFoundset has new records or JSRecord is a new record.
Sample
var fs = databaseManager.getFoundSet(databaseManager.getDataSourceServerName(controller.getDataSource()),'employees'); databaseManager.startTransaction(); var ridx = fs.newRecord(); var record = fs.getRecord(ridx); record.emp_name = 'John'; if (databaseManager.hasNewRecords(fs)) { application.output("new records"); } else { application.output("no new records"); } databaseManager.saveData(); databaseManager.commitTransaction();
hasNewRecords
(foundset, index)
Parameters
{JSFoundSet} foundset – The JSFoundset to test.
{Number} index – The record index in the foundset to test (not specified means has the foundset any new records)
Returns
Boolean – true if the JSFoundset has new records or JSRecord is a new record.
Sample
var fs = databaseManager.getFoundSet(databaseManager.getDataSourceServerName(controller.getDataSource()),'employees'); databaseManager.startTransaction(); var ridx = fs.newRecord(); var record = fs.getRecord(ridx); record.emp_name = 'John'; if (databaseManager.hasNewRecords(fs)) { application.output("new records"); } else { application.output("no new records"); } databaseManager.saveData(); databaseManager.commitTransaction();
hasRecordChanges
(foundset)
Parameters
{JSFoundSet} foundset – The JSFoundset to test if it has changes.
Returns
Boolean – true if there are changes in the JSFoundset or JSRecord.
Sample
if (databaseManager.hasRecordChanges(foundset,2)) { //do save or something else }
hasRecordChanges
(foundset, index)
Parameters
{JSFoundSet} foundset – The JSFoundset to test if it has changes.
{Number} index – The record index in the foundset to test (not specified means has the foundset any changed records)
Returns
Boolean – true if there are changes in the JSFoundset or JSRecord.
Sample
if (databaseManager.hasRecordChanges(foundset,2)) { //do save or something else }
hasRecords
(foundset)
Returns
Boolean – true if the foundset/relation has records.
Sample
if (elements.customer_id.hasRecords(orders_to_orderitems)) { //do work on relatedFoundSet } //if (elements.customer_id.hasRecords(foundset.getSelectedRecord(),'orders_to_orderitems.orderitems_to_products')) //{ // //do work on deeper relatedFoundSet //}
hasRecords
(record, relationString)
Returns
Boolean – true if the foundset/relation has records.
Sample
if (elements.customer_id.hasRecords(orders_to_orderitems)) { //do work on relatedFoundSet } //if (elements.customer_id.hasRecords(foundset.getSelectedRecord(),'orders_to_orderitems.orderitems_to_products')) //{ // //do work on deeper relatedFoundSet //}
hasTransaction
()
Sample
var hasTransaction = databaseManager.hasTransaction()
mergeRecords
(sourceRecord, combinedDestinationRecord)
Sample
databaseManager.mergeRecords(foundset.getRecord(1),foundset.getRecord(2));
mergeRecords
(sourceRecord, combinedDestinationRecord, columnNames)
Sample
databaseManager.mergeRecords(foundset.getRecord(1),foundset.getRecord(2));
void
recalculate
(foundsetOrRecord)
Parameters
{Object} foundsetOrRecord – JSFoundset or JSRecord to recalculate.
Returns
void
Sample
// 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)
Sample
//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);
releaseAllLocks
()
Returns
Boolean – true if all locks or the lock is released.
Sample
databaseManager.releaseAllLocks('mylock')
releaseAllLocks
(lockName)
Returns
Boolean – true if all locks or the lock is released.
Sample
databaseManager.releaseAllLocks('mylock')
removeTableFilterParam
(serverName, filterName)
Sample
var success = databaseManager.removeTableFilterParam('admin', 'higNumberedMessagesRule')
void
revertEditedRecords
()
Returns
void
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)
void
revertEditedRecords
(foundset)
Returns
void
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)
void
rollbackTransaction
()
Returns
void
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(); }
void
rollbackTransaction
(rollbackEdited)
Parameters
{Boolean} rollbackEdited – call rollbackEditedRecords() before rolling back the transaction
Returns
void
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(); }
void
rollbackTransaction
(rollbackEdited, revertSavedRecords)
Returns
void
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
()
Returns
Boolean – true if the save was done without an error.
Sample
databaseManager.saveData(); //databaseManager.saveData(foundset.getRecord(1));//save specific record //databaseManager.saveData(foundset);//save all records from foundset // when creating many records in a loop do a batch save on an interval as every 10 records (to save on memory and roundtrips) // for (var recordIndex = 1; recordIndex <= 5000; recordIndex++) // { // foundset.newRecord(); // someColumn = recordIndex; // anotherColumn = "Index is: " + recordIndex; // if (recordIndex % 10 == 0) databaseManager.saveData(); // }
saveData
(foundset)
Returns
Boolean – true if the save was done without an error.
Sample
databaseManager.saveData(); //databaseManager.saveData(foundset.getRecord(1));//save specific record //databaseManager.saveData(foundset);//save all records from foundset // when creating many records in a loop do a batch save on an interval as every 10 records (to save on memory and roundtrips) // for (var recordIndex = 1; recordIndex <= 5000; recordIndex++) // { // foundset.newRecord(); // someColumn = recordIndex; // anotherColumn = "Index is: " + recordIndex; // if (recordIndex % 10 == 0) databaseManager.saveData(); // }
saveData
(record)
Returns
Boolean – true if the save was done without an error.
Sample
databaseManager.saveData(); //databaseManager.saveData(foundset.getRecord(1));//save specific record //databaseManager.saveData(foundset);//save all records from foundset // when creating many records in a loop do a batch save on an interval as every 10 records (to save on memory and roundtrips) // for (var recordIndex = 1; recordIndex <= 5000; recordIndex++) // { // foundset.newRecord(); // someColumn = recordIndex; // anotherColumn = "Index is: " + recordIndex; // if (recordIndex % 10 == 0) databaseManager.saveData(); // }
setAutoSave
(autoSave)
Parameters
{Boolean} autoSave – Boolean to enable or disable autosave.
Returns
Boolean – false if the current edited record could not be saved.
Sample
//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)
void
setCreateEmptyFormFoundsets
()
Returns
void
Sample
//this has to be called in the solution open method databaseManager.setCreateEmptyFormFoundsets()
void
startTransaction
()
Returns
void
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)
Sample
//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')