Error: object is not an instance of declaring class

I have a function that I’ve used for some time with no trouble that has started giving me an error.
The error I get is

Error while performing method with name emptyMailing, id 5957
details
object is not an instance of declaring class

Here is the code for the method emptyMailing

var theOpressedButton = plugins.dialogs.showQuestionDialog('Confirm', 'Empty This Mailing?', 'YES', 'NO');
if(theOpressedButton == 'YES')
{
	forms.mailing_contact_rel.controller.find();
	forms.mailing_contact_rel.fk_mailing_id = forms.mailing.id_mailing;
	forms.mailing_contact_rel.controller.search();
	forms.mailing_contact_rel.deleteAllRecords();
}

The code is meant to delete all records in a table called mailing_contact_relation, for a giving mailing_id.

I think the problem may have started after upgrading to the newest servoy version. R2 2.1.2-build 315. At least I can’t remember it not working before doing that, and I can’t remember it working after doing that. I have java version 1.4.2_05-b04 (Windows 2000).

Does anyone know what may be causing this problem. I haven’t changed this code at all, but is it possible that changing something else in servoy would stop this from working?

msampson:
forms.mailing_contact_rel.deleteAllRecords()

isn’t the .controller missing in your line of code?

try with:

forms.mailing_contact_rel.controller.deleteAllRecords()

It was missing and adding it fixed the problem. Not sure if it got delete by accident or for some reason it worked without it for a while. Either way thanks for catching that.

HOT TIP: DO NOT TYPE. Use the tree and double click - or use the typeahead code completion:

type g then CTRL + SPACE and you’ll see contextual auto-complete.

:)