onInvertRecordsCmd Causing Loop Error?

Hi,

I’ve got a form with the onInvertRecordsCmd event handler set to: globals.methods.navigationOnInvertRecordsCmd.

The navigationOnInvertRecordsCmd method is:

currentcontroller.invertRecords();
globals.navigationSetGuiMessageString(); // This updates an “x of y” label in a custom controller

When I choose Select>Invert Records, I get this error: “Cycle detected, function navigationOnInvertRecordsCmd called 22 times”.

Any ideas?

(navigation.SetGuiMessageString is:

var currentRecord = currentcontroller.getSelectedIndex();
var totalRecords = databaseManager.getFoundSetCount(forms[currentcontroller.getName()].foundset); // Per Servoy’s note, getFoundSetCount is an EXPENSIVE OPERATION
forms.navigation.elements.lbl_guiMessageString.text = "Record " + currentRecord + " of " + totalRecords;

and doesn’t cause problems anywhere else when called similarly.)

Thanks,

JDW

Have you tried dropping the FIRST line in your script (currentcontroller.invertRecords())?
I would suspect that line to cause the cycle

HTH

Hi, Thanks for the note.

I DO want to invert the records, I just need to do it via my own method so I can update the custom controller. So, I can’t drop the invert records. (Not sure why that would loop as well…)

JDW

I understand but in order to determine where your problem is coming from, I would be nice to know what line is causing the problem and I’m guessing the problem is the first line

If the problem would be a bug (for instance) that causes the Invertrecord command to run anyhow, you calling the invertrecords manually would cause a loop (like servoy was indicating in his errormessage.

So, I can’t drop the invert records. (Not sure why that would loop as well…)

Well, I guess Odysseus has a point.

Seems like you are attaching a script that inverts records, to an onInvertRecordsCommand…
Once the script starts running and inverts the recordset, it will trigger the 0nInvertRecordsCommand which has the very same script attached to it…and round you go

Hi,

Thank you both for your notes. When I comment out the “currentcontroller.invertRecords();” line, there is in fact NO loop.

However, I do need this as I want to invert the records and then update a GUI “x of y” count.

I AM calling invertRecords() from and onInvertRecordsCmd event handler on a form. If this is causing a loop, it seems very inconsistent behavior compared with the other Form event handlers. For example, I have NO issues with looping for the following:

onOmitRecordCmd → calls currentcontroller.omitRecord();
onShowOmittedRecordsCmd → calls currentcontroller.loadOmittedRecords()
onShowAllCmd → calls currentcontroller.loadAllRecords();
onFindCmd → calls currentcontroller.find();
onSearchCmd → calls currentcontroller.search();

Thanks for further help…

JDW

Hi,

Just a bump here… could someone from Servoy comment on what looks like a bit of inconsistent behavior as I noted above?

Our preference would be that invertRecords() does not cause the onInvertRecordsCmd() event handler to fire, just as currentcontroller.find() doesn’t fire/loop the onFindCmd() handler.

Thanks!

JDW

Its a bug, will be fixed in 2.2.1 final

Thank you!

JDW