Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

Relationship to show most recent 10 records


This topic is 8218 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi Everyone,

I've struggled with this one once before, and ended up using a scripted solution, but I'm not really happy with using scripts if I can avoid it.

Basically, I am trying to set up a relationship that links to the most recent 10 records created. If anyone can tell me how, I'd be much obliged.

Obviously I could just set a portal to only have 10 lines, but that doesnt help for a web based solution. I really need there to be only 10 related records.

Cheers,

Sean.

Posted

Create a field that auto-enters serial numbers, increments of one (rec_number). Make sure it's a number field. Create another field that does a calc on it, basically comparing its own rec_number field against the Max(rec_number) of the entire table. If it's within 10, then it returns a "Y", if not, a "N".

Base your relationship for the ten most recent on the Y or N value of the record, which updates itself as records are added. No scripts needed.

I attached a small file that does just that, with a cutoff variable field too so you can easily set it show 10, 5, 3, 20, etc.

10_recent.zip

Posted

Thanks for the effort Sharka.

But, I still can't see how this would work.

On my machine, max_rec_number always equals rec_number, so most_recent_YN always equals "Y".

Were you able to actually get a portal to only display the 10 records? Self-related is fine by me.

Cheers,

Sean.

Posted

Hmm, I see what you mean. I fixed the Max field thing. The reason a relationship won't work though is because the calc field upon which the portal would depend cannot be indexed. frown.gif

Basically, because the 'last ten' is a moving target, it's difficult (if not impossible) to quantify it in an indexed manner. This means that it's also difficult to base a relationship on the moving target (of whether it belongs to the last ten records or not).

This can be done easily through scripting, but you want no scripts.

If this is for the web however, you could use my attached solution, and simply hardcode the Lasso search to find records where the value is "Y". It doesn't care if the field it's searching is indexed or not.

I've attached a simpler setup

10_recentv2.zip

Posted

Great, Sharka, you gave me enough to solve it that time.

I don't have Lasso, but what you propose sounds like it could be fairly slow, searching non-indexed fields.

I've attached my example in case anyone else can use it.

Technically all records appear in my portal, but only the most recent lines (qty set by user) appear, which is what I need.

For others to reference I put the CDML coding I'll use in there too (basic as it is).

Thanks for you help,

Sean Collier

recent_v3.zip

This topic is 8218 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.