invertRecords()

Questions, tips and tricks and techniques for scripting in Servoy

invertRecords()

Postby maria » Wed Jul 11, 2012 9:19 am

Hi guys,

I'm not sure if I'm using invertRecords() properly because it returns an empty foundset whereas there's clearly records in the table.
So, I have my foundset that I get with var fs = databaseManager.convertFoundSet(trackingRecords, trackingRecords.foo_to_bar);
My converted fs now has two records and there are 8 records in total in the table.
So I execute fs.invertRecords() to exclude my current two records and bring up the other six - but it doesn't happen, I have an empty foundset instead.

What am I doing wrong? :roll:

Cheers,
Maria
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: invertRecords()

Postby omar » Wed Jul 11, 2012 11:47 am

Hi Maria,

What I did to try and reproduce you problem is create a orders form and a order_detail form. To reduce the ammount of records I put the order form in find mode and filtered on just one order. Then I used the following code to create and bind the converted foundset:

Code: Select all
var convertedFoundSet = databaseManager.convertFoundSet(foundset, orders_to_order_details);
forms.orderdetails.controller.showRecords(convertedFoundSet);


This then shows the order_detail records for the selected order. When I invert:

Code: Select all
var fs = forms.orderdetails.foundset;
fs.invertRecords();   


then it shows all orderdetail records except the orignally selected one which is what you would expect.

So the question is how do you filter the 6 records out from the 8? Because that's what Servoy probably needs to succesfully do an invert. I am guessing it's not with a find/search?

Also note that Servoy does not literally invert. If the table has 300 records and 200 records are available in the foundset. Then an invert will not show the other 100 records from the table. So it actually only inverts your filtering criteria.

Hope this helps a bit.
Intrasoft, Founder
Omar van Galen
omar@intrasoft.nl
+31-(0)6-21234586
Servoy Developer
omar
 
Posts: 377
Joined: Sat Feb 12, 2011 4:51 pm
Location: Intrasoft, The Netherlands

Re: invertRecords()

Postby maria » Thu Jul 12, 2012 2:25 am

omar wrote:Hi Maria,

What I did to try and reproduce you problem is create a orders form and a order_detail form. To reduce the ammount of records I put the order form in find mode and filtered on just one order. Then I used the following code to create and bind the converted foundset:

Code: Select all
var convertedFoundSet = databaseManager.convertFoundSet(foundset, orders_to_order_details);
forms.orderdetails.controller.showRecords(convertedFoundSet);


This then shows the order_detail records for the selected order. When I invert:

Code: Select all
var fs = forms.orderdetails.foundset;
fs.invertRecords();   


then it shows all orderdetail records except the orignally selected one which is what you would expect.

So the question is how do you filter the 6 records out from the 8? Because that's what Servoy probably needs to succesfully do an invert. I am guessing it's not with a find/search?


Hi omar,

I didn't say I filtered anything.
I grabbed one foundset, converted it to a related foundset with the matching records which resulted in two records as expected.
The other 6 records did not match the conversion criteria, so they were clearly left out.
Now I want to see them, so I invert my two records foundset but see an empty foundset.

Cheers,
Maria
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: invertRecords()

Postby omar » Thu Jul 12, 2012 1:33 pm

Do you have filtering criteria in the relation? Normally, the convertFoundset method should get all child records that are related to the available records in the parent foundset and the invertRecords should succesfully be able to invert the result. Anyway, that's how it works in my tryout sample.
Intrasoft, Founder
Omar van Galen
omar@intrasoft.nl
+31-(0)6-21234586
Servoy Developer
omar
 
Posts: 377
Joined: Sat Feb 12, 2011 4:51 pm
Location: Intrasoft, The Netherlands

Re: invertRecords()

Postby maria » Fri Jul 13, 2012 2:07 am

omar wrote:Do you have filtering criteria in the relation? Normally, the convertFoundset method should get all child records that are related to the available records in the parent foundset and the invertRecords should succesfully be able to invert the result. Anyway, that's how it works in my tryout sample.


Ok, I get what you're saying, omar.
Thanks for explaining that, I didn't realise the relation is involved and expected that all records will be inverted no matter how the foundset was filtered/related.

Cheers,
Maria
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney


Return to Methods

Who is online

Users browsing this forum: No registered users and 8 guests

cron