# form used by itself and in a tab panel

**URL:** <https://forum.servoy.com/t/form-used-by-itself-and-in-a-tab-panel/1008>\
**Category:** Classic Servoy\
**Created:** [January 12, 2004, 6:18pm UTC](https://forum.servoy.com/t/form-used-by-itself-and-in-a-tab-panel/1008 "2004-01-12T18:18:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DFehrenbach](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@DFehrenbach](https://forum.servoy.com/u/DFehrenbach)\
**Post date:** [January 12, 2004, 6:18pm UTC](https://forum.servoy.com/t/form-used-by-itself-and-in-a-tab-panel/1008/1 "2004-01-12T18:18:44Z")

</div>

I have a form that sometimes I use as a normal list form, and sometimes as a form displayed in a tab panel from another form and table. On a field in this form is an onAction button to bring up a record form in dialog of other fields pertaining to the record in the table.  
Obviously, when the form is used as a list form, the correct record is shown, but when the form is displayed as a tabpanel in another table, the method shows the records from the first record in the file,not the proper related record. How can I code the method so that it will get the correct record regardless of from which form it is called?

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [January 12, 2004, 6:33pm UTC](https://forum.servoy.com/t/form-used-by-itself-and-in-a-tab-panel/1008/2 "2004-01-12T18:33:19Z")

</div>

I’ve had this struggle as well. ![:)]( "Smile")

One thing you need to remember about Servoy is “context.” The context you’re in at the moment will determine everything. When you use the listview by itesel - the context is the list view - so the script works. If you show the listview in a tabpanel - then the “context” is that of the master record you’re displaying.

Here’s what I do:

1. Create a global field;

2. The first line in the script of the button set the global field to the primary key of the record you’re clicking on;

3. Create a relation (global key to child database) - and load the record based on that relation.

Now it will work in every context.

Hope this helps,

Bob

---

<div class="post-metadata">

**Author:** ![DFehrenbach](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@DFehrenbach](https://forum.servoy.com/u/DFehrenbach)\
**Post date:** [January 12, 2004, 8:24pm UTC](https://forum.servoy.com/t/form-used-by-itself-and-in-a-tab-panel/1008/3 "2004-01-12T20:24:35Z")

</div>

Thanks for your quick response!  
I don’t know where I’m going wrong!  
Attached is the scheme for the forms.

1. I’ve created a globals.matterid field
2. I’ve created a relation _globalmatterid\_to\_matter_ from Matter file to Matter file using globals.matterid equals matterid.
3. method attached to Matterlist2 form record line:

> //viewMaDetail[MatterList2]  
> globals.matterid=matterid  
> controller.loadRecords( globalmatterid\_to\_matter)  
> application.showFormInDialog( forms.maDetail, -1, -1, -1, -1, “Matter Details” );

Now, when I click on a line from normal list view, the correct record is displayed in dialog, but when the dialog is dismissed the rest of the found set is removed. I underestand how this happens from the loadrecords step in the method, but how do I get my previously found set back?

When I click on a line when the form is displayed in tabPanel (called from form clDetail0) all of the fields in the dialog are blank. ![:cry:]( "Crying or Very sad")  
I’m lost in tabpanel hell!

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [January 12, 2004, 8:39pm UTC](https://forum.servoy.com/t/form-used-by-itself-and-in-a-tab-panel/1008/4 "2004-01-12T20:39:59Z")

</div>

Can you upload (or email) me your solution [bcusick@servoy.com]?

I can help you out.

Bob Cusick

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [January 12, 2004, 8:46pm UTC](https://forum.servoy.com/t/form-used-by-itself-and-in-a-tab-panel/1008/5 "2004-01-12T20:46:27Z")

</div>

Maybe this approach helps:

In the crm demo there 's a create button in the contactslist that’s attached to this script:  
if(currentcontroller.getName() == “companyDetails”)  
{  
controller.newRecord()  
company\_id = forms.companyDetails.companiesid  
}  
else  
{  
plugins.dialogs.showDialog(‘Alert’,‘Contacts may only be created in Companies’,‘OK’);  
}

It simply checks in which main form you are currently in.  
(the script will only create a new contact record when you are in  
company details. (there’s a tabpanel there "Contacts’ that is actually the same form as contacts list.)

---

<div class="post-metadata">

**Author:** ![DFehrenbach](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@DFehrenbach](https://forum.servoy.com/u/DFehrenbach)\
**Post date:** [January 12, 2004, 10:43pm UTC](https://forum.servoy.com/t/form-used-by-itself-and-in-a-tab-panel/1008/6 "2004-01-12T22:43:23Z")

</div>

Thanks Maarten, but I think my real problem is not knowing what form I’m in at any point in time, particularly with regard to tabpanels.  
For example, in the scheme above, I know when i’m in clList form, when I click on a record line from the list, I switch to clDetail0, but then, when I click on the tab panel for matterlist2, which form am I in? clDetail0 or materlist2? ![:?]( "Confused")

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [January 13, 2004, 8:49am UTC](https://forum.servoy.com/t/form-used-by-itself-and-in-a-tab-panel/1008/7 "2004-01-13T08:49:32Z")

</div>

clDetail0

currentcontroller.getName() always returns the main form you’re in.  
(even if you trigger a script inside a tabPanel)
