# Showing related records with showFormInDialog

**URL:** <https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638>\
**Category:** Classic Servoy\
**Created:** [September 4, 2004, 7:24am UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638 "2004-09-04T07:24:11Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [September 4, 2004, 7:24am UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/1 "2004-09-04T07:24:11Z")

</div>

I have a form, Panels. On that form is a button to popup another form which will display all of the members of the currently selected panel.

To show the form I do:

application.showFormInDialog(forms.panel\_members, -1, -1, -1, -1, " Panel Members ")

That part is working fine.

To limit the records displayed in the panel\_members form, before the line above I do:

forms.panel\_members.controller.loadRecords(panel\_members\_to\_panels2)

When it hits that line I get the following error: Can’t set a foundset from table panels into a form using table panel\_members.

The panel\_members\_to\_panels2 relation joins the two tables on the id\_panels field.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [September 4, 2004, 8:10am UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/2 "2004-09-04T08:10:58Z")

</div>

is your form: panel\_members maybe atatched to the table: panels?

It looks that way

Than your method does not work. You are trying to set a foundset between tow different tables!!

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [September 4, 2004, 8:23am UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/3 "2004-09-04T08:23:56Z")

</div>

No. My panel\_members form is attached to the panel\_members table.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [September 4, 2004, 8:45am UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/4 "2004-09-04T08:45:21Z")

</div>

Ah now I see,

you are trying to set the form: panel\_members with a foundset of: panels.  
That is not ppssible.

here is an example of how loadRecords works:

```auto
forms.panels.controller.loadRecords(panel_members_to_panels2)

```

now your are setting the form: panels with the right foundset!

So in yourexample you have to make another relation the other way:

```auto
forms.panel_members.controller.loadRecords(panels2_to_panel_member) 

```

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [September 4, 2004, 8:58am UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/5 "2004-09-04T08:58:29Z")

</div>

I tied that:

forms.panel\_members.controller.loadRecords(panels\_to\_panel\_members)  
application.showFormInDialog(forms.panel\_members,5,130, 510, 500, " Panel Members ")

It doesn’t give me an error, but it doesn’t do the job either.

When the form opens, all of the panel members, for all panels are showing. I only want to show the panel members for the selected panel.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [September 4, 2004, 9:01am UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/6 "2004-09-04T09:01:06Z")

</div>

than you have to check your relation: panels\_to\_panel\_members

it should work this way. I use it alot.

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [September 4, 2004, 10:03am UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/7 "2004-09-04T10:03:46Z")

</div>

Attached is a picture of the relation window. Let me know if you think I’m doing anything wrong. The primary key of Panels is id\_panels plus id\_projects.

Thanks.

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [September 8, 2004, 9:40am UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/8 "2004-09-08T09:40:36Z")

</div>

is the relation valid when you call loadRecords?  
try application.output("count "+panels\_to\_panel\_members.getMaxRecordIndex()) to see in your output window how many records are in there before calling loadRecords

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [September 8, 2004, 1:07pm UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/9 "2004-09-08T13:07:58Z")

</div>

Jan,

When I put that line of code in:

```auto
application.output("count "+panels_to_panel_members.getMaxRecordIndex()) 
forms.panel_members.controller.loadRecords(panels_to_panel_members)
application.showFormInDialog(forms.panel_members,5,130, 510, 500, " Panel Members ")

```

I get an error message: “Cannot convert null to an object”

If I go to Tools/Relations the panels\_to\_panel\_members is listed as part of the panels table but it is not listed in the editor under relations for either the panels\_one\_member form on which I am clicking or the panel\_members form that I want to open.

I’m not sure what to do about it…

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [September 8, 2004, 1:25pm UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/10 "2004-09-08T13:25:05Z")

</div>

> gstein:  
> I get an error message: “Cannot convert null to an object”

Thats what I thougth you are passing null to loadRecords…  
You are using the relation from within the wrong form or it is not defined at all (is named different) ,did you move the code? or type it yourselfs?

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [September 8, 2004, 1:37pm UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/11 "2004-09-08T13:37:20Z")

</div>

I created the relation myself.

When I created the one or both of the panel forms, I may have copied a different form and then changed the referencing table and other properties of the controls in the properties window.

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [September 8, 2004, 2:34pm UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/12 "2004-09-08T14:34:37Z")

</div>

Thats not what I mean, in the editor treeview on a form node is a relations subnode, can you move the relation “code” (with move code button) into your script?  
Moving code makes sure the syntax is valid and you are accessing it the right way (handy incase you are not sure)

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [September 8, 2004, 3:08pm UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/13 "2004-09-08T15:08:55Z")

</div>

In the editor treeview I have two panel forms, both based on the panel\_members table. They both have the same list of relations – but the relation I want is not listed there at all. I can only see the relation I want by going to the Relations window and looking at the Panel (not Panel Members) table.

When I popup the Panel Members form, I want to limit the records to only the related Panel that is currently selected on the Panels\_One\_Member form.

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [September 8, 2004, 4:39pm UTC](https://forum.servoy.com/t/showing-related-records-with-showformindialog/2638/14 "2004-09-08T16:39:43Z")

</div>

> gstein:  
> – but the relation I want is not listed there at all. I can only see the relation I want by going to the Relations window and looking at the Panel (not Panel Members) table.

Exactly, this means that relation is not accessible from the that form, the form table must be the same as the left side table from the relation.
