separate found sets in the same table

I am having trouble figuring out how to share a form between two found sets in the same table at the same time.

Main form (clList) shows a list view of found set for table

A method may find a group of other records in the table and show them in a list form in dialog: (clSearchList - uses a separate found set)

a button on the formindialog list should trigger a method to display the details of the selected record in clSearchList:

application.showFormInDialog( forms.clDetail0, -1, -1, -1, -1, ‘Client Details’, true, false, false)

When this method is executed the clDetail0 form is displayed but it is displaying fields from the record of the first found set (clList).

How do I specify that I want to display the fields from the second found set attached to clSearchList? I want to preserve the original found set on the Main form.

I am not really sure but I think this is not possible. A foundset belongs to a form so when you show the form a second time and change the foundset you change them for both. But again, I am not sure about this…

set the foundset of the clSearchList in the clDetail form before you show them.

then clList will still have the normal foundset and clDetail will have a copy of the clSearchList.

Thanks Johan! I’ve changed the method in clSearchlist to the following:

//viewClientDetails[clSearchList]
set = controller.duplicateFoundSet()
forms.clDetail0.controller.loadRecords(set)
application.showFormInDialog( forms.clDetail0, -1, -1, -1, -1, ‘Client Details’, true, false, false)

and it works perfectly.
Now, however, when I go back to clLIst evidently the original foundset is no longer active in that form. When I execute the cList script to view the details of the current cList record:

// viewClientDetail[cList]
forms.clDetail0.elements.tabs_70.tabIndex=1
application.showFormInDialog( forms.clDetail0, -1, -1, -1, -1, ’ Client Details ', true, false, false)

The detail that shows is the detail from the clSearchList record.
Now, I realize that I am using the same form to view separate records in the same table and I’ve just set the foundset in clDetail0 for the clSearchList form set, so it makes sense that when I return to clList and show a record with the clDetail0 form, that I would get the record from the previous found set.
I guess my assumption was that when I returned to clList the original found set would take over when I displayed the clDetail0 form.
Am I going about this in the correct way? Is there an easier way?

I jsut want to give you one hint.
Always Always Always give the foundset with the show command ..
Or always set the foundset before showing in a dialog.

Never just show the form. (maybe that method shouldn’t never have been there…)

if you have 3 forms

clList, clSearchList and cdetails

and you want to keep the foundset you have in clist when going to the clSearchList..

Make clSearchList an useSeperateFoundset form.

Then there is no need to duplicatate youre foundset youreself.. We are already doing that if you are setting a foundset of one form in a use seperate form. Also the other way around!! So if you set the foundset of a use seperate form to a non seperate form we will make a copy so that the seperate form always have a seperate foundset

so if you have the clList and you go to the clSearchList set the foundset:
forms.clSearchList.showRecords(foundset)
then if you go to the clDetails form in a dialog:

forms.clDetails.loadRecords(foundset);
application.showFormInDialog( forms.clDetail0, -1, -1, -1, -1, ‘Client Details’, true, false, false)

then when you return to the clList it should have the same foundset when you left it. (if clSearchList == seperate)

What you also can do is store a foundset in a javascript variable..
And then set that back when you show the clList form..

onhide:
myFoundSetStore = foundset;

onshow
if(myFoundSetStore)
{
loadRecords(myFoundSetStore)
}

but when you first show the form it won’t have the myFoundSetStore so in the onload you should make it first:

myFoundSetStore = null;