You have two methods in Filemaker 11 for controlling what records show in the portal:
- The relationship on which the portal is based.
- A portal filter expression can be set so that only related records for which the filter expression evaluates as true are displayed.
In older versions, you can only use the first method.
If you have a field in the portal record that records employee status as "active" or "inactive", this portal filter expression would filter out all related employee records:
Employees::Status = "Active"
There are ways to do this with method 1 if you are using an older version of FileMaker so let me know if that is the case and I'll post a way to do that as well.
I have FM 10 Advanced.
There are ways with method 1 as well to make it semi dynamic
How is this done?
You can create a field set to global storage in your layouts table then create a relationship between that field and your employees status field.
You can then set that global field on the layout in a number of ways. (script,dropdown list, radio button, etc)
If you wanted to change list in the portal from active to inactive you would change the value in this global field.
A little more infor as to the table the layout is based on would help.
We have an "Employees" table that has a field called "Active".
We have a "Contacts" table that has a field called "Type", where if it is an employee the selection is "Employee". There is also a field called "Active" that holds the value of either 'active' or 'inactive'. It is generic because all types of "Contacts" uses it as well. When the value is entered in the "Contacts" layout it enters the value in both tables?: "Contact" & "Employees".
You mentioned to create a global field, but which table does it go in?
Also, I only need to display in the portal the employees that are "Active" at that moment in time.
How do I do this?
What relationship do you currently have between Contacts and Employees that you use for this portal.
It seems that you are storing the active status in contacts rather than employees and that turns things inside out from what I was originally assuming here so I'd like to see what relationship you are trying to use here.
The relationship between both tables is: "__kp_ContactID" on the "Contact" table, and "_kf_ContactID" on the "Employee" table.
Also, on both tables that have the following option selected : "Allow creation of records in this table via this relationship."
The "Active" status is located on both tables. On the "Contacts" table is for an "Active" contact. If they are an "Active" contact and they are an employee, then the "Active" status is entered into the "Employee" table.
Our layout that has the portal is "Tasks_EditTasks".
When I click on the portal, a portal setup window pops up. It displays : "Show related records from : 'Tasks_AllEmployees".
If I right-click on the field in the portal it pulls data from : "Tasks_AllEmployees::AccountName".
If I double-click on that field, it has a related script assigned to it : "Tasks_SelectPerson".
The code for the script is:
Set Field [Notes::_kf__AccountNames; AddValues (Tasks_AllEmployees::AccountName & "|1")]
Set Field [Notes::_kf__AccountNames; AddValues (Tasks_AllEmployees::AccountName)]
Go To Field
That script was created by the original programmer.
I believe it retrieves the the "AccountNames" from that field.
Open the layout with your portal in layout mode and check "show records from" in Layout setup....
Then Open Manage | Database | Relationships and find Tasks_AllEmployees and whatever name you find in that Show Records drop down.
How are they related?
That name, "'Tasks_AllEmployees", suggests a relationship different from just matching by contact ID numbers, it suggests you may have a different relationship entirely. See if the = operator or X is used in the relationship.
I'm looking for the answer to this question: Do you see all employees in the employee table in the portal or is this relationship supposed to show "all employees working for the contact in the current contact record"?
From "Home" it goes to "Notes" via "z_CurrentAccountName" to "_kf_AccountNames".
Then from there it goes to "Tasks_AllEmployees" via "__kp_NoteID" to "g_SelectedNote".
The last question of yours, the response is : it shows all employees (both "active" and "inactive").
But what table occurrence is listed in Show Records From in layout setup for this layout? That's a key question here.
It sounds like you have this relationship:
LayoutTableOccurrenceName::anykey X Employees::AnyKey
I'm using the field names "anyKey" here because with the X operator (instead of =), you can use any field on either side of the relationship and you get the same results. (All employee records are displayed no matter what record is current for "LayoutTableOccurrenceName".) I'm using LayoutTableOccurrenceName here because that name should match the name in Show Records From and You haven't checked that detail for me yet.
That would list all records from employees no matter what record you are on in Contacts, but we need to be sure of the details here.
It seems like "Active" status should be only in contacts or only in Employees--unless an "Active" contact is not the same thing as an "active" employee. (It just seems redundant to have to enter the same status twice here.)
The portal is taking from the occurence : "Tasks_AllEmployees".
The reason why is because in "Contacts", the "Status" is to let users know if those contacts are "Active" or "Inactive". Our users can only access certain layouts with table data to corresponding contact type. Users in a certain department can view for example the "Employees" layout. While other can view the "Patients" layout and others the "Agents" layouts, etc. That is why the "Contacts" layout is visible to everyone. Thats where the main information is entered for contacts of all types. For example, name, address, phone number, email, etc. Then when a record is created contact type specific fields can be entered in the contact type's layout, for example : Client, Agent, Employee, etc.
I'm asking about what you see in Layout Setup.. not portal setup... It's the relationship between the name in Layout Setup...|Show Records From and Portal Setup...|Show Records from that will tell us what is currently set up for your portal so that I can take a stab at modifying it to filter out those employee records that are not "active".