Hi all,
I saw some code today that was trying to load records into a form using a relationship, and sort the records all in one step:
forms.theTargetForm.loadRecords(forms.utilityForm.utilityForm_to_TargetForm_relationship.sort('aField ascending'')
This is part of a larger method that creates a new record and performs a find on the utilityForm. What is odd is that starting up the client and running this routine the first time will not load the related records into theTargetForm. In the debugger I saw that forms.utilityForm.utilityForm_to_TargetForm_relationship.getSize() returned 3, but 42 records ended up getting loaded into theTargetForm. Running the routine again after this first failure works as expected. Taking out the sort from loadRecords step and sorting on a separate line causes the code to work as expected always, including the first time run after startup.
This is in servoy 4.1 I’d just like to know if sorting in the same line of code as loading the records is not recommended, and if so, why? What is it about this code that caused it to misbehave on the first run after a startup?
Thanks,
-Jeremy