How can I reuse a form instance?
If I close the formindialog containing it, I can no longer recall it until I close the developer or I change the name of the newInstanceScriptName).
I tried simply closing the window or using a closeFormInDialog instruction.
do you have a quick example what you mean?
jcompagner:
do you have a quick example what you mean?
Sure:
var ok = application.createNewFormInstance('offers_list_tab','test');
if (ok)
{
application.showFormInDialog(forms.test)
}
If I call the method, I get a FID called “test”. But if I close it and i re-launch the method, the FID is not opened anymore…
Which completely correct…
The FId is only opened if “application.createNewFormInstance(‘offers_list_tab’,‘test’);” returns true.
In your case, the second time you run the method, that code will return false, because it was not able to create a newinstance with the name test, because in the previous run you allready created a form with the name test. You cannot have two forms with the same name!
You should probably change your code to:
var ok = application.createNewFormInstance('offers_list_tab','test');
if (ok || forms.test)
{
application.showFormInDialog(forms.test)
}
Paul
pbakker:
Which completely correct…
The FId is only opened if “application.createNewFormInstance(‘offers_list_tab’,‘test’);” returns true.
In your case, the second time you run the method, that code will return false, because it was not able to create a newinstance with the name test, because in the previous run you allready created a form with the name test. You cannot have two forms with the same name!
You should probably change your code to:
var ok = application.createNewFormInstance('offers_list_tab','test');
if (ok || forms.test)
{
application.showFormInDialog(forms.test)
}
Paul
Now I got it (and it works, thanks Paul and Johan).
But, since the form “test” is not visible when I close the formindialog, couldn’t be a good idea to have a “discard” function available?
I mean, something to get rid of a form instance like application.removeFormInstance so I don’t have to check if the form already exists or not…
What do you think?
we could have such a method yes where you can clean up/destroy form objects.
jcompagner:
we could have such a method yes where you can clean up/destroy form objects.
Great. Should I fill a feature request?
please make a case yes.
The problem with destroy is that the form is also not cached. So if you do show the dialog often then it is not very wise to always kill it.
so i don’t know if it really brings more you could also have something like
if (!forms.test)
{
// create
}
showFormxx()
jcompagner:
please make a case yes.
The problem with destroy is that the form is also not cached. So if you do show the dialog often then it is not very wise to always kill it.
so i don’t know if it really brings more you could also have something like
if (!forms.test)
{
// create
}
showFormxx()
Good point. I’ll think about it. 
In any case, I suggest to include the explanation to default behaviour in the docs…
Thanks, Johan
I’m sure that once 3.5 is final and the docs are there, it will be in there.
The function is new in 3.5 and the docs will be updated once 3,5 is final.
BTW: the new instance will be cleared out of the cache automatically when you don’t use it anymore after a certain time anyway, so in my opinion, you don’t need a specific function for it. just let Servoy manage that, as it allready does with normal forms.
Paul