I’m a newbie here, and I’ve got a question that is complicated to explain, so I’ll try my best to make my setup clear.
I've got three tables with relationships:
1st Table: "Owners" - has fields for:
2nd Table: "Milestones" - has field for:
3rd Table: "Projects" - has fields for
On a layout based on the table “Projects”, I’ve got a various portals:
PortalA is a single-row portal that shows property owner information from the table “Owners” (Unique Owner ID number, First Name, Last Name, Address, etc.). There can be multiple property owners in any given “Project”. The PortalA shows Owner ID and info of the currently selected owner (selected from a separate list I’ve placed in the layout).
In PortalA, I’ve given the “OwnerID” filed an object name of “OwnerID” in the Inspector.
PortalB shows certain milestones we’ve reached with the specific property owner in the Project. The table for PortalB is based on the table “Milestones”. Each owner has his own milestones, so the relationship is “Owners::OwnerID_pk---<=>---Milestones:MilestoneID_fk”.
In the Milestones table, I’ve got a field called “Owner_Milestone” that is populated via a checkbox Value list. So when a new milestone record is created, I have a script that does this:
- Go to the Milestone layout
- Set a unique ID number in Milestones:ID_pk
- Set Milestones:ID_fk to match Owners:ID_pk
- Record creation date in Milestones::CreationDate
- Record chosen value from the checkbox value list into Milestones::Owner_Milestone
Ok, so everything is working great here.
On to my question:
In my Projects Layout, I have a single-row portal called PortalC based on “Milestones” with just one field: Milestones::CreationDate. And I want to filter that portal (“Filter portal records” in Portal Setup) based on the following 2 criteria
- Get the ID of the active owner shown in PortalA and apply that ID in the filter
- Scan through the records for “Milestones”, looking for that specific OwnerID and look for a specific text string. For example, search for “Contract Signed”
My end goal is have the Milestones::CreationDate field in PortalC say “Hey, I see that owner John Smith with ID 3 is the active portal row in PortalA and I’ve gone through his related records in “Milestones” and I’ve found an occurrence of “Contract Signed” and here’s the CreationDate that Milestones record was created.
For the above 2 criteria, I have found working calculations for each:
- Let ( $id = GetLayoutObjectAttribute ( "OwnerID"; "content" ) ; Milestones::ID_fk = $id )
- Milestones::Owner_Milestone = "Contract Signed"
Each of the above calculations work on their own, but I can’t figure out how to apply both of the criteria in the “Filter portal records” calculation.
I’ve tried filter calculations like:
Milestones::Owner_Milestone = "Contract Signed" & Let ( $id = GetLayoutObjectAttribute ( "OwnerID"; "content" ) ; Milestones::MilestoneID_fk = $id )
Let ( $id = GetLayoutObjectAttribute ( "OwnerID"; "content" ) ; Milestones::MilestoneID_fk = $id & Milestones::Owner_Milestone = "Contract Signed")
But none of the above work (again, I'm a newbie, so please forgive the above attempts).
Any ideas from the experts?