I would like to have a button on my main form that allows only the records that have related (portal) records to be displayed. I cannot figure out how to do this. Can someone point me in the right direction?
Also, is there a way to do a “find” (from the menu) on the information in a portal and return only the main records containing the desired portal information.
Just to be sure we’re thinking the same:
assuming you have a company list,
you’d like to have a button(search) that displays (for instance) only the companies that have contacts?
That is correct. We have a list of parts, and only some are on our published price list. I want to find only the parts that have price list entry information (contained in the portal).
I must be doing something wrong. I tried what you suggested and did not see any results (method returned all parent records).
When I interactively do a “Find” I can only enter criteria in the parent record fields, not into the portal record fields, so I cannot simulate the search interactively. Is it correct that one cannot search portal records interactively?
I am stuck - seems like it should be easy to do. Any ideas?
I thought perhaps that it should be the second way, then realized that we
were replicating what would be entered in the field while doing an interactive search.
Should I be able to search interactively for portal records?
When I do an interactive search on my form that contains the main item data plus the portal for the related child records I can only enter criteria in the parent record fields. There are no visible child record fields in which to enter a search criteria. Perhaps I have something set wrong?
I have two tables:
Items (parent on form)
PriceListData (child on form)
They are related through ItemID which is text field in the Items table (where it is the primary key) and a text field in the PriceListData table (where it IS NOT the primary key). This is a one (Item) to many (PriceListData) relationship.
I have tried searching on PriceListData.ItemID >0 and also PriceListData.PriceListDataID (the primary key) >0 with no success.
Is there an easy way to send you my solution file?
The fact that you are using textfields as keys in your relationship changes everything.
If you do a search on a textfield you can’t say “give me everything >0”.
This should work:
//script in the main form (companies)
controller.find()
companies_to_contacts.contactsid = ‘!^’
controller.search()
The search now looks for all related records where contactisid is not null.(in other words > DOES have a value)
(also press F1 (Help) and check the search data section)
Assuming you want to go from contacts to companies,
create next method on the contact list form.
//create an array with all pk's of the parent records
var pkArray = new Array();
for(var i=1 ; i<=foundset.getSize() ; i++)
{
var record = foundset.getRecord(i)
pkArray[i] = record.company_id
}
// remove duplicate pk's
//this link explains next code [url]http://www.planetpdf.com/developer/article.asp?ContentID=6389[/url]
var unduped = new Object;
for (var i = 0; i < pkArray.length; i++)
{
unduped[pkArray[i]] = pkArray[i];
}
var uniques = new Array;
for (var k in unduped)
{
var x = unduped[k];
if(x)
{
uniques.push(unduped[k]);
}
}
//convert the uniquePkArray (uniques) into a dataset
var pkDataset = databaseManager.convertToDataSet(uniques)
//load the foundset in the parent form using this pkDataset
forms.companies.controller.loadRecords(pkDataset);