You could use a Find, but this can be done in one step using Go to Related, and specify the relationship used in the contacts portal.
You can use Go To Related Record for this or you can script a find.
Set Variable [$CompID ; YourTable::CompanyID]
Go to Layout [//layout referencing portal records table]
Enter Find mode
Set Field [PortalRecordstable::CompanyID ; $CompID]
Set Error Capture [on]
The above script assumes you have a unique serial number ID for each company (Much better approach than to use company names which may not be unique and are also subject to change), set up as the primary key that links it to your portal records.
Go To Related Records is a very useful tool, but can be hazardous if you don't properly trap for errors. To learn more about GTRR, click the following link:
The Complete Go To Related Record
The last step is Perform Find not Perform Find/Replace
I changed it, but it still isn't working. It still shows all contacts from all companies.
What layout are you on when you run this script?
I am on the Company Layout.
Hmm, I suspect we have two problems here.
- Company_ID does not have unique serial numbers here--any chance this field is empty?
- The script won't produce the desired effect even when that problem is fixed.
I suggested the script as a way to find the related portal records on a different layout.
You script appears to start on "Company Contact List" and then performs a search on this same layout. All this script will do (if it works) is isolate the current record on in a single record found set.
If you want to pull up all the records listed in the portal, Go To Related Records does this in one step and can make the portal row you clicked the current record in this new set of found records.
My serial number is Customer_ID and is unique and auto-entered....Should i be using this instead of $CompID?
I want the related [Contacts] from [Company_List] to be shown in a layout called Company_Contacts_List which has field from both these tables.
$CompID is needed in order to get the company ID value correctly entered while in find mode.
Remove the Set Error Capture step and run the script to see what error message pops up.
I suspect the error message will tell you that no criteria was entered.
If you bring up portal set up for your portal. What do you see in "Show Related Records from"?
No error message pops up.
It's working now though.
It may fail if you run it while the bottom blank portal row is selected/active.