show related records of multiple parent records

Hi there,

How can I show the related records of multiple parent records easily.

Say for example I have a foundset of 10 company records in frmCompany (company table). I want to show all their related employee records in the frmEmployee (employee table). Is there a special method that does this?

I am wondering how to do this? Thanks for your advise.

There’s a converting function in the databaseManager node of the Editor.

attach this script to the frmCompany

//next line creates a new foundset Object (convertedFoundSet) based on the arguments
// -foundset (your current prmFoundset)
// -relation name  company_to_employees
var convertedFoundSet = databaseManager.convertFoundSet(foundset,company_to_employees);
//the next line shows the new "convertedFoundSet" in the form employees.
forms.employees.controller.showRecords(convertedFoundSet);

Cheers! This worked great!!

Do you think if I have a larger foundset then issuing this command be a major problem??

Thanks

In terms of what do you mean this?
Speed? > depends on what kind of relation you’re using.
Normal indexed pk>fk shouldn’t give you any problems.

Ok! Thanks!

How can I go to a single related record without breaking the foundset?

Can you specify more? which foundset do you mean?
Assuming you’re going from company form to employee form I don’t see how you would break a foundset. Both company form and employee form have their own found set, simply because they are built on different tables.

Say for example I am going to the employee foundset from company form by doing a convertFoundset and loadRecord using that foundset. This will take you to a full list of employees for the foundset of company records. This is working great!
Then I navigate through each records in the employee records.
Suddenly I wanted to go back from a employee record to its corresponding company record in the previous company foundset.

If I use frmEmployee.controller.loadRecords(employee_to_company) it will load that particular company record that employee is related to (will break the company foundset), instead of just going to the particular record in the foundset of companies (will not break company foundset). Of course it can break the foundset if related company is not in the previous company foundset. How can I do this??

Thanks

going back from employees to companies without altering the foundset of companies:

//this script is attached to employees form .
//company_id is the fk in employees
//set record selection in the companies foundset with the company_id (=foreign key in employees)
forms.companies.foundset.selectRecord(company_id);
//just show the form
forms.companies.controller.show()