A list view does not go through a relationship, you are looking at the base table of the layout you are on when you are in the list view. It is not like a portal where you are looking through the relationship.
To filter a list view you need to reduce the found set, i.e. perform a find.
List view shows the "Found Set" of record, so, Yes, you need to control it with a search. Or you could arrive there via a GTRR (go to related records) script step. If using GTRR, you have to set the script step options to show only related records if you don't want everything.
This becomes increasingly difficult with complex queries.....darn it.....Using the relationships would make so much sense....
So with this search that I need I would have to create a list of keys that are related by means of a relationship and script so that it searches for those keys. Quite a few extra steps and tweaking wishing it was the other way around. Why isn't it?
You are expecting that with a relationship of
TableOccurrence1 -- TableOccurrence2
simply entering a layout based on TableOccurrence2 would perform a Find / act as a filter equivalent to the predicates of the relationship definition.
wishing it was the other way around. Why isn't it?
That cannot work for several reasons:
1) Being on a record of TableOccurrence1 gives you a context to resolves the predicates in the relationship and find a matching set. If you are in a layout of TableOccurrence2, what record from TableOccurrence1 should constitute that context?
TableOccurrence1 -- TableOccurrence2 -- TableOccurrence3
Now which of these two relationships should act as the filter for a layout based on TableOccurrence2?
If you want to use the "query" encoded in the relationship predicates, go to a record of TO1 and use Go to Related Record with target TO2 and 'matching only'; or construct a Found Set in TO1 and use GtRR with the additional option 'match all in found set'.
So with this search that I need I would have to create a list of keys that are related by means of a relationship and script so that it searches for those keys.
You already have the keys since you already have a working portal. Just grab those values that are making the relationship work and do a find with those values mimicking your relationship. Your script would look like
Enter find mode
Or as StephenHuston pointed out before go to your source record and use "Go to related record" do go to the subset of records.
I think Stephen Huston's suggestion is the best for what you want (GTRR) even though I hate that function because you can't look at it in a script and see what it does without opening it (which is why I just manually do the script steps to go to a new layout and perform the find).
I probably would approach this different by using a virtual list and SQL. Just my preference because there are lots of ways to achieve the same results in FM.
I ended up using the GTRR script. It worked out well. Thanks everyone.