Declaring class puzzle

Prior to upgrading to 2.1.1 the following code worked fine, I swear. It’s intended to jump to to the last record in the current foundset. Operates via a custom controller to a tab panel.

var tp = forms.companyMain.elements.tabs_70.tabIndex;
if (tp == 1)
{
	var max = currentcontroller.getMaxRecordIndex(); // yields 29
	forms.comDetails.setSelectedIndex(max);
}

Now it presents this error message:

Illegal Argument Exception: Object is not an instance of the declaring class.

Have not come across this error before. Anyone know what it means, any guesses condition it’s pointing to?

you don’t have a setSelectedIndex directly on the form.
you have to do through the foundset or the controller.

But that code is completely strange. First you ask the max record index through the currentcontroller.

Then you use that value on a different form (ofcourse it can be the same but errors are around the corner)