new instance

I am trying to display several instances of the same form in a formindialog.
as soon as another instance is displayed, the previous instance gets blanked.
normal effect? I guess no, otherwise what would be the purpose of several instances!?

Hi lesouef,

Make sure the new instance uses a separate foundset. Then it will work.

what do you mean? I have tried to display different records, no change.
I have tried to find records before creating the new instance, same. after, same.
I have the feeling servoy only has one foundset per table.
What is exactly a new foundset if not another set of found records? I am very suspicious about servoy and its weird vocabulary sometimes, they already invert search and find, use invert instead of complement…

Okay, let me start at the beginning.

First. Each form that uses tableA will share the foundset on that table. So when you add/delete or change record selection it will show up in all those forms without extra coding on your part (which is very nice!).
Now there is a form property named ‘useSeparateFoundset’ which gives this specific form it’s own foundset on this table disconnected from all the other forms.

Second. Showing a form in different tabpanels doesn’t make it a new instance of this form. It’s still pointing to the same form object.
You can’t show the same form instance in different tabpanels at the same time.
This is where the new application.createNewFormInstance() function comes in place.

If all this is too much coding/trouble you can simply create 2 (or more) forms in Developer and give them separate foundset.

Hope this helps.

thks for the quick reply.
I had noticed the common found set which is handy most of the time.
What I want to do is not to display the same foundset in several tabs, but 10 windows using the same form with 1 record each. and so far, only the last instance works. Can I get 10 foundsets, how do I swicth to the foundset N?
Should I create the new foundset before or after the new instance?
All fuzzy to me this…

If you want 10 windows with 10 different foundsets then you need 10 instances of this form (with the useSeparateFoundset property enabled).
You can fill these foundsets the way you do with shared foundsets as well.

controller.loadRecords(SQL, [arrayWithParams])
// or 
controller.loadRecords(foundsetOfAnotherForm)
// or
controller.loadRecords(DataSet)
// or
controller.loadRecords(ArrayWithPKs)

Or link the form over a relationship.
And you load the foundset after an instance is created.

So in a word there is no real difference other than it uses it’s own foundset disconnected from any other.

Hope this explains it better.

ok, I got it. for others information, here is what I did:

var $pin_id = labels_to_pins.pin_id ; //record id taken from a a portal
var $instance = “pin” + $pin_id ; //instance and window name

application.createNewFormInstance (“pin” , $instance );
application.showFormInDialog( $instance, -1, -1, -1, -1, $instance , true, false, $instance , false);
currentcontroller.loadRecords($pin_id);

forgot the main thing…
thanks you Robert!

fuck, the thing does not work anymore after the file has closed and re-opened.
it works except that it does not load the right record but always the 1st one.
so it seems I was on another foundset for some reason…
makes me mad. why is it so complex to get a bloody record in a subwindow?
it works if I do a find in the new window, why is loadrecords(id) not always calling it?

Excuse me.
I seem to have made an error in my examples.
You can’t use an array with PK’s to load a foundset but you need to convert that into a DataSet.

var ds = databaseManager.convertToDataSet([4,5,6]);
controller.loadRecords(ds);

In your code you don’t use any of my examples but put the PK directly in the controller.loadRecords(). That won’t work.
Your code should look like this:

var $pin_id = labels_to_pins.pin_id ; //record id taken from a a portal
var $instance = "pin" + $pin_id ;  //instance and window name

application.createNewFormInstance ("pin" , $instance );
application.showFormInDialog( $instance,  -1, -1,  -1,  -1,  $instance ,  true, false, $instance ,  false);
currentcontroller.loadRecords(databaseManager.convertToDataSet([$pin_id]));

lesouef:
fuck, the thing…

We all know programming can be frustrating sometimes. We’ve all been there, but I think I speak for all of us here on the forum when I say to please refrain from such strong language on this forum.

Hope this gets you further.

did it.
it works fine, same as the temp non smart solution I had done in between which was find/define field/search.
I am unfortunately facing an extra step, the formindialog does not display on the client side while ok on developer.
I’ll post another thread for this if I can’t fix it, I have not been working on it yet.
as for f…, ok, I apologize. but it is frustrating to be stuck, especially when you can’t achieve what you can do with other other tools in seconds.

10 forms for 10 conditions of the same form is probably the least favorable approach in servoy.

Unless you need to show all 10 conditions at the same time, use one form and events to show what you want depending on the condition.

Yes, not easy, but it works ok by now.
I’ll let you know why I need this if you’re interested in. basically to use small windows to show a specific area, kind of post-its.