I’m trying to learn to use the window plugin’s showFormPopup correctly in regards to scope. I currently have a form that I open for use by adding it to a tabpanel, and then deleting it from the tabpanel when I’m done. Within the code for the form are references to a relation going from the form’s foundset to a tenant record. It works fine when used in the tabpanel example, but when I try to use the form in showFormPopup, I’m getting an error, and I suspect that the problem is with the scope that I’m specifying. I’ve tried using “this”, but beyond that, I’m not real sure what accepted values are for the scope. The doc for the plugin has a couple of examples, but nothing that provides a thorough explanation of how scope works for this function. (It could be that I just don’t understand scope very well within Javascript as well).
I was wondering if someone could provide a link to some further explanation of what the correct usage is for this in Servoy.
As always, thanks for any guidance that you might be able to provide.
Thanks for your response, and a happy holiday season to you
I’m going to continue to experiment here and see what happens. I’m a bit unclear to me as to how I reference what’s in the scope when I’m on the popup. For example, if I put a record in the scope, what’s the correct way to reference it in the popup? In the example code, you have this…
plugins.window.showFormPopup(null, forms.orderPicker, foundset.getSelectedRecord(), “order_id”);
When I get to the popped up form, is the scope saying that when I get to “forms.orderPicker” I have access to the data in “foundset.getSelectedRecord()”? Or do I just have access to “order_id”? And if the foundset for the popped up form also has an “order_id” (let’s say as a foreign key), what’s the correct way to syntactically reference one vs the other?
Here’s why I’m asking…
I create a new “art show” record, and ask the user if they want to create a reminder for this show. If they do, I’ll popup the form for the reminder record, which is tied to the show, so it carries along the show_id as a foreign key. (That allows me to do things like put the name of the show on their calendar and things like that) To do that, I need to somehow pass the show_id to the popup form so that it can insert it into the reminder record as it’s being created. For my example, would the correct syntax be…
plugins.window.showFormPopup(null,forms.showtable,foundset.getSelectedRecord(), “show_id”)?
If that’s correct, how do I reference the “show_id” in the popup to insert it into the reminder record, since the popup now has a show_id passed to it from the popup command, as well as a show_id in it’s foundset record?
I’m looking at this thinking that I’m missing something really obvious, but I’m just not seeing it right now.
As always, thanks for any guidance you can provide.
no the scope is not for referencing it in the popup
the popup is just a form, that has its own scoping
the scope is purely for setting the value that your method returns.
you open a form X from Fom Y that form Y gives it record (or itself as the formscope) to the showPopup()
then form X says: closePopup(value)
then that value is set to the scope that form Y did give to the showPopup
So Form X doesn’t have to know anything about the caller and its return value can go anywhere, that is just defined by the caller.
Between your explanations and my own experimenting, I think I’m beginning to understand it better. So, the scope isn’t really there as a mechanism for passing parameters as you might with a function call; if there was something that I needed the popup to have access to, I could just put that into a global variable where it’d be easily accessible from anywhere. I think that I will try it that way.
After much experimenting and discussion, I think that what I’ve concluded is that my problem was basically that showFormPopup wasn’t the appropriate tool for what I was trying to accomplish. I’ve moved over to using globals.DIALOGS.showFormInModalDialog instead. My initial tests are showing this doing what I what I want to do. Hopefully, I’ll get consistent operation in the web client as well, and further testing will verify that.
Thanks again for your insights, Johan. Appreciate it.
form popup is not a modal dialog, nor is it meant to replace it.
Form popup is more like the combobox list popup when you collapse the combobox.
But then way nicer or complex.
Yep, I would say that that’s exactly what I learned by experimenting with this. I’ll be honest that I’m still not real clear on the scope part of showformpopup, but that’s just part of my learning process.