Counter intutive puzzle

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Counter intutive puzzle

Postby Morley » Fri Feb 25, 2005 10:14 pm

I have a form with a record already loaded. I then run this code. The relationship "gint1$to_sec" is globals.gint1 = security_id (both integers). There's a filter in place (controller.addFoundSetFilterParam). globals.gint1 = 48 and security_id = 48 is a record within the parameters of the current filter.

Code: Select all
forms.secFeatures.controller.loadRecords(gint1$to_sec);
var max = forms.secFeatures.controller.getMaxRecordIndex(); // resolves to 1

However, if the form doesn't have any records the relationship fails and no records are loaded. Therefore I add this code:

Code: Select all
var gint1 = globals.gint1; // resolves to 48
var max1 = forms.secFeatures.controller.getMaxRecordIndex(); // resolves to zero
if ( max1 == 0 )
{
   forms.secFeatures.controller.loadAllRecords();
   var max2 = forms.secFeatures.controller.getMaxRecordIndex(); // resolves to 5
   forms.secFeatures.controller.loadRecords(gint1$to_sec);
   var max3 = forms.secFeatures.controller.getMaxRecordIndex(); // resolves to zero
}

Halting the routine right after "controller.loadAllRecords()" and before the "controller.loadRecords(gint1$to_sec)" I can clearly see the target record among the current set.

What's going on here? What am I missing?
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby bobcart » Sat Feb 26, 2005 2:56 am

Although you don't say it, I assume the problem is that your if statement resolves to true even if you have a record? For the little it's worth, I don't see anything wrong in the code. However, there have been several reports of relation problems recently. Globals in relations stopped working for me reliably after the beta release with modules (see here: http://anon.free.anonymizer.com/http:// ... f1bd0201e7 ) Pretty bad stuff that it can even change data!

Also, I've found that scripting with foundsets while using addFoundSetFilterParam is flakey for me. Add to this a global relation and you will have a debugging challenge for certain. You might try replacing addFoundSetFilterParam with find/search to reduce that challenge. If that doesn't do it, you may have to replaace the global relation with another approach.
bobcart
 
Posts: 214
Joined: Fri Nov 21, 2003 8:01 pm
Location: Melbourne (AUS)

Postby Morley » Sat Feb 26, 2005 5:12 pm

bob cart wrote:Although you don't say it, I assume the problem is that your if statement resolves to true even if you have a record?

Not quite. The relationship works just fine if there's already a record present.

But not if there's no record, even if I then load all records (run loadAllRecords(), thus bringing in the current filtered set), and then loading the record in the global relationship. It's this specific sequence that causes failure -- no records, loadAllRecords(), loadRecords(global relationship). To repeat, if there's already a record present and I run loadRecods(global relationship), it works. To me, that's counter intuitive.

Note again that the record in the global relationship is among the current filtered set and is clearly seen when running the loadAllRecords().

Definitely feels like a bug. Would appreciate a comment from the Servoy staff.
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby bobcart » Sat Feb 26, 2005 11:11 pm

I've seen several bug reports similar to this, but it seems no one has reduced it to its simplest form so it is easy for the servoy team to fix. Maybe this issue will stand out?

Anyway, in the second block of code, forcing the load all records probably wont help since that is followed by loadRecords(gint1$to_sec) which would replace whats there - so no need for the if statement block at all. The problem is probably not whether a record is in the foundset when you run the script. The problem must be in loadRecords(gint1$to_sec) - or perhaps addFoundSetFilterParam.

Make sure the globals.gint1 relationship is valid when you load records (the evaluate tab in the debugger is good for that). If its good when you fire the loadRecords, and you still get nothing, suspect the filter param. If you can get the bug to appear without the filter param, youd have reduced it to a very simple level, i.e. loadRecords doesnt work with global relationships. If it works without addFoundSetFilterParam then you know where the problem is.

Good luck!
bobcart
 
Posts: 214
Joined: Fri Nov 21, 2003 8:01 pm
Location: Melbourne (AUS)


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 1 guest

cron