losing data in web client by searching

I seem to have found a bug. I have a web client solution. Sometimes when I search for some data in a particular column, i get all the matching records, but all the columns have been emptied.
Say there are 5 records with a particular string in a given column. I perform a search on that column for that string. I get 5 results. The trouble is that all the columns for those 5 records are now empty, including the one I searched on. I’ve just lost all that data. If I do the same search again, I now get zero results. It’s rare that this happens and I haven’t noticed a pattern.

One thing I have noticed is that only those records that are shown on the screen get emptied. If there are 40 search results, but only 30 fit on my screen at a time, the first 30 get emptied. If I click to the next page, I see the other 10 records and all the data is still there.

Servoy 6.0.3
PostgreSQL

Can you post the code that you use for the search?

var columnNames = null;
var searchCriteria = null;

function performSearch()
{
      globals.vMessage = '';
      var s
      if (isNaN(searchCriteria))
      {
           s = '#%' + searchCriteria + '%';
      }
      else
      {
           s = searchCriteria;
      }
      controller.find()
      if(controller.find())
      {
            foundset[columnNames] = s
            controller.search()
            elements.searchCriteria.selectAll();
      }
      else
      {
            globals.vMessage = 'Could not enter Find mode.';
      }
}

adamk:

controller.find()
  if(controller.find())
  {
        foundset[columnNames] = s
        controller.search()
        elements.searchCriteria.selectAll();
  }
  else
  {
        globals.vMessage = 'Could not enter Find mode.';
  }

}

Why do you have controller.find() twice?
I suggest you to always check if you really are in find mode before searching, using the following code you can be sure of that (cause the only reason for controller.find() to fail is when you have unsaved changes):

if(!controller.find())
{
 databaseManager.saveData()
 controller.find()
}

Usually when you suffer data loss and find mode is involved is due to the fact that find mode failed and the search criteria are entered in the dataproviders instead. It’s always a good idea to save before finding or at least ask the user.

ngervasi:
Usually when you suffer data loss and find mode is involved is due to the fact that find mode failed and the search criteria are entered in the dataproviders instead. It’s always a good idea to save before finding or at least ask the user.

That’s not happening, though. The search criteria isn’t being entered into the dataprovider. The dataprovider, and all the other columns in the table, are being emptied completely.

I have new information about the problem. I was in form that consists only of fields in a table. I performed a search and got the results that I wanted. Then I did another search and got no results. I performed the first search again, and this time I got the same number of results as the first time, only all the fields were empty. The all the fields in every record that match my search criteria had been emptied. I reentered the missing data, then did another search for which there were no matching records. I then performed the first search a third time and the fields were emptied again. I had to reenter the data a second time.

Put more concisely, it seems that if I do a search and there are no matching records, the next search for which there are matching records clears out all the fields in those records.

Weird but if it’s reproducible create a case in the support system.

It is hard to believe that Servoy clears or delete data, but if data is deleted, you should also see, some delete statements in the servoy-admin page…

did you have a look there?

Harjo:
It is hard to believe that Servoy clears or delete data, but if data is deleted, you should also see, some delete statements in the servoy-admin page…

did you have a look there?

I don’t think Servoy would log any of this because no records are being deleted. The only thing that’s happening is that the fields are being emptied. It’s as if I clicked into each field and pressed backspace.

I did some experimenting and I discovered something important. Here’s what happens:
I type some search criteria and click the Go button, which has a method attached to it that performs the search. No matter what I do, I never lose any data by clicking Go.
If I do the same thing, but press Enter instead of clicking the Go button, I lose data. Also, it only happens following a search for which there are no matching results. I perform a search, there are no results. I perform another search for which there are results. If I had clicked Go for the second search, no problem. If I had pressed Enter, the fields get emptied. I’ll examine the methods to see if I can find a bug in the code.

Execute some code to get the changed records output to the console after you have the issue, it’s the best starting point to debug.
Check also if you are still in find mode or not when you see the empty records in your table view.

I discovered that pressing Enter and clicking the Go button both run the same method. Whatever the problem is is not caused by the method alone. As a workaround, I’ve made it so that the Enter key no longer runs the method.