This is a simple application that displays a customer record and associated transactions. The customer record displayed is determined by the login username. So I am trying to filter the foundsets from the SQL Server data tables to only have the records for the relevant customer. I have tried the code below in the form OnLoad, the OnShow and also in the login form when a successful login happens:
var currentUsername = utils.stringTrim(security.getUserName());
var currentAccount = '';
var customerFoundset = databaseManager.getFoundSet('statements', 'customer');
if (customerFoundset.find())
{
servoyusername = currentUsername;
if (customerFoundset.search())
{
currentAccount = customerFoundset.accountcode;
}
}
currentAccount = utils.stringTrim(currentAccount);
var success = databaseManager.addTableFilterParam('statements', 'customer', 'accountcode', '=', currentAccount, 'accountfilter');
However this produces the following in the server log:
2011-12-12 15:54:46,310 ERROR [http-8080-3] com.servoy.j2db.util.Debug - Error executing sql: update customer set servoyusername=? where accountcode = ? and accountcode = ? with params: ['CAR000101' ,type: java.lang.String, 'ADA0001 ' ,type: java.lang.String, 'ADA0001' ,type: java.lang.String]
com.servoy.j2db.util.ServoyException: Update/insert failed, unexpected nr of records affected: expected 1, actual 2
Why is it trying to update the customer table? I’m searching on it!