controller.find()

Does anyone know any reason why calling controller.find() in a method would not put the form into find mode?

Today I observed Servoy 4.1 running a method that calls controller.find(), and sometimes the form does not go into find mode, so instead of searching, the method actually does data entry when setting the fields. We stepped through this with the debugger to confirm. We evaluated a field after executing controller.find() and the value was not null. If this error does happen it seems to happen only on the first attempt after launching the smart client. It’s very odd that this would happen only occasionally. Any ideas on what it could be? Has anyone else ever even seen this?

Thanks,
-Jeremy

controller.find() returns a boolean, you should always capture for a failure to enter find mode, like…

if(!controller.find())
   // do something to handle the error

The most common reason to fail entering find is invalid records that can’t be saved.

greg.

We have confirmed through the debugger that a save does occur.
Any other possible reason?

jkipling:
We have confirmed through the debugger that a save does occur.
Any other possible reason?

saveData() returns a boolean indicating if the save was successful. You should check if it returns true or false.
A save can fail if you’re trying to save invalid data, like a null in a field that doesn’t allow nulls.

The save happens successfully, my first thoughts were invalid data too. But it has nothing to do with the data. It can happen or not happen on the same record. It seems to only happen soon after logging into the database.

I should rephrase that. I think ultimately it does have to do with the data, but it just doesn’t make sense what it could be since the data is the same when it works and doesn’t work. There is no servoy validation or not allowing null. I’m leaning toward this being a Sybase error, but still not sure.

Can it be that there are pending records in the foundset, waiting to be saved? It occurred to me that when a calculation gave a different result than the stored value because of rounding differences. Then those records came in the edit buffer (auto-save was false) and the find failed.