Servoy 6.0 release candidate 5

rossen,

this is some kind of state that shouldn’t really happen yes, it would be nice to know how you get that foundset in that state.
The good thing is that it won’t affect you at all, and the record will not be null…

		if (selectedIndex == -1 && fc.getFormModel().getSize() > 0)
		{
			Debug.error("No selection set on foundset with size " + fc.getFormModel().getSize() + " fs: " + fc.getFormModel(), new RuntimeException());
			fc.getFormModel().setSelectedIndex(0);
		}

as you can see if we detect this state, we log it so we know that it did happen, and then we set the selection to the first record.
(which will be returned then)

So from your code, the flow is normal, but yes somehow the foundset is in a wrong state, how that happens we would like to know.