It depends on what you're conditionally highlighting, and where it is. If you're on Table (as opposed to RelatedTable), and you're asking about a related table's field, then the FIRST value for that related table is the one that will be evaluated. That's why you're seeing the behavior where if the first record you add contains the text, your conditional formatting is applied.
Are you wanting to conditionally highlight something in the related record? If so...put the object you want to apply the formatting to in the portal. Are you wanting to highlight something in the record you're viewing based on something in a related record? Then you need to approach it in a different way. Also...you may want to use PatternCount rather than "=". It depends.
If you want to highlight something any time a pattern of "text" occurs in the records related to the one you're viewing, you might use something like PatternCount ( List ( RelatedTable::RelatedField ) ; "Text" ).
'PatternCount ( List ( RelatedTable::RelatedField ) ; "Text" )'
This works. Thanks for the help and the quick reply.
OK so I have another condition that I need to apply.
Each of the records in the related field have a time stamp.
I need the condition to apply only if the record containing related field 'Text' content is NOT followed by (based upon the time stamp) a record containing different content: 'OtherText'.
Does that make sense?
Flesh it out a bit. Are you looking at a list view of records with portals to related records on each record? Is it:
Record 1 has related records 1, 2, 3 and one of those related records contains 'Text', so highlight.
Record 2 has related records 1, 2, 3 and NONE of those related records contains 'Text', so unhighlight record 1.
What you're asking is possible...just flesh it out a bit more with what you're after. Screen shots would help, too.
Record 1 (Context) has related records (a history) that consists of 2 fields ('occurrence name' and 'date') along with an fk_ID field
occurrence name is a text field
date is a timestamp
Conditional formatting should be applied IF occurrence name 'X' is preset in the related history AND it has a more recent 'date' than all other events with the occurrence name 'Y'.
'X' and 'Y' can happen multiple times in the related history but the 'date' make those records unique.
Is that helpful?
Getting close...and you want to highlight something in Record 1 (Context)? Or in one of the related records?
The context record.
If you can send a screen shot with actual data, that would be helpful. I'm thinking offhand that the easiest way to accomplish what you're after is something involving ExecuteSQL. You're going to need to determine the most recent date for X and for Y. It sounds like something I'd do in a Let statement, which involves enough specificity that real-world examples would be incredibly helpful. I realize it might be confidential data.
It sounds like you're using a direct reference to a related field. When you do that, FileMaker evaluates it as it if were only the first record in the related set. That's why it doesn't change for the different related records.
You might want to look at the GetNthRecord function (FileMaker Pro 15 Help) to allow you to extract the value of a specific related record.
There is a link to my test file.
The 'event' of 'Approved' triggers the conditional formatting.
The functionality/conditionality I want is that if the 'event' of 'Change Requested' is inputed at a more recent date the conditional formatting does not apply.
That way the history of approvals stays intact and the conditional formatting is applied only when 'Approved' is more recent than 'change Requested'.
I'm taking a look now. In the meantime, when a portal allows record creation, that last record "appears" to be present, so you get a garbage can on a row that appears empty. Users will sometimes think they should delete the blank record, but when they click the trash can, nothing happens. For that reason, I usually hide buttons when the ID of the related record is empty.
Hide when IsEmpty ( z_fkID_Projects ), for instance.
I am using that in my real document. Thanks.
I created this on the fly and just didn't take the time to add that functionality.
i sincerely appreciate how helpful you have been with all of this.
The attached file is one way to accomplish what you're after. Give it a test and see if it'll work for you.
Couple of things you'll have to dig into.
1) When you make a calculation such as List ( RelatedTable::Field ), the list will be made based on the sort order of the RELATIONSHIP, not the portal. So I've sorted the relationship in descending order by your Date field (which is a Timestamp field). That way...the most recent event will always occur first in your list.
2) I've added a script trigger which fires OnModify in the event field. As soon as an event is created, records are committed, which causes the refresh and therefore the calculations will be evaluated.
3) I've created a Let statement which looks at the Positions of each of your types of Event. If an Event hasn't occurred, that event is set to "" (as opposed to zero). A list of the occurring events is generated, the Minimum position is evaluated, and if it's the same as the first occurrence of "Approved", then Approved is first in the list, so highlighting (or unhiding) will occur. I'd go with the Hide condition instead of Conditional Formatting in this instance. Conditionally formatting to white has issues when rows or backgrounds have colors.
There are no doubt a lot of different ways to go, and others will have improvements on the formula I'm using. But...the formula is readable as is so hopefully it'll give you an idea of how it's working.
Here's the formula, which evaluates to 1 (true) if Approved is first, and 0 if it is not first.
FirstApprovedInList = Position ( List ( History::event ) ; "Approved" ; 1 ; 1 ) ;
FirstChangeRequestInList = Position ( List ( History::event ) ; "Change Request" ; 1 ; 1 ) ;
FirstNewPrototypeInList = Position ( List ( History::event ) ; "New Prototype submitted" ; 1 ; 1 ) ;
FirstApprovedInList = If ( FirstApprovedInList > 0 ; FirstApprovedInList ; "" ) ;
FirstChangeRequestInList = If ( FirstChangeRequestInList > 0 ; FirstChangeRequestInList ; "" ) ;
FirstNewPrototypeInList = If ( FirstNewPrototypeInList > 0 ; FirstNewPrototypeInList ; "" ) ;
FirstToOccur = Min ( FirstApprovedInList ; FirstChangeRequestInList ; FirstNewPrototypeInList )
FirstToOccur = FirstApprovedInList ; 1 ;
I think I'd prefer to use ExecuteSQL. How do I limit the SQL to just the related records and not all records?