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

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

Recommended Posts

Posted (edited)

Hi folks.  Can GetNthRecord be used from the context of a TO related to the one that it's doing the 'getting' in, or can it only do the getting from the context of the TO that it's doing the getting in?  Thanks

Edited by fmpfan
Posted

If I'm on a layout that's connected to Table A, and I want to get the 5th record on related Table B, can GetNthRecord do that?

Posted

If I'm on a layout that's connected to Table A, and I want to get the 5th record on related Table B, can GetNthRecord do that?

​If you define a calculation field in Table A as =

GetNthRecord ( Table B::Valuefield ; 5 )

it will get data from the 5th related record in Table B. In this example, it doesn't matter which layout you happen to be on.

 

Posted (edited)

In this example, it doesn't matter which layout you happen to be on.

​... unless different layouts have different base 'table occurrence names' for Table A.

You can get different results based upon the underlying table occurrence name of the layout you are on ( Layouts > Layout Setup > Show Records From ) and how that relates to its table occurrence of TableB - depending upon any relational filters and sort in THAT particular relationship from Table A to Table B.

Well, I didn't explain it as well as Michael (Comment) but I think it is important to mention.  Perspective is everything in FM, for sure. :-)

Edited by LaRetta
added ( Layouts > Layout Setup > Show Records From )
Posted (edited)

​... unless different layouts have different base 'table occurrence names' for Table A.

​​If you define this as a calculation field, and there are different A TOs that are related to B, then the result depends on what A TO is selected for “Evaluate this calculation in the context of”".

Therefore, it doesn't matter what A TO the layout is based on where you display that A calc field.

And yes, I know you know this … :D

Edited by eos
Clarified calculation "field"
Posted (edited)

Sometimes folks reading can glean the wrong impressions because we leave out bits or pieces of an explanation (heck, we can never provide ALL details)  ... I would rather have someone speak up, as you are doing Oliver, than give someone wrong impression.

However, it depends also upon whether defining a calculation or simply asking through a script.  A calculation has the option of specifying different perspectives; scripts do not - they only see from their layout perspective.  

Thanks for adding that depth, Oliver, it is appreciated.

added ... we don't really know HOW this is being used here since it is not specifically in Calculations or Scripts section.

Edited by LaRetta
Posted (edited)

we don't really know HOW this is being used here since it is not specifically in Calculations or Scripts section.

​Indeed. This is precisely why I stated explicitly "​If you define a calculation field in Table A as ...". I then said that it doesn't matter which layout you happen to be on. I wanted to emphasize that the calculation field will still return the same result when you are on a layout of Table B.  But it will in fact still return the same result even if you move to another TO of A. It will still look at the Nth related record, using the same relationship.

I suspect that fmpfan will come back and tell us that's not how he wants to use GetNthRecord(), but I thought I would at least move this forward a bit.

 

Edited by comment

This topic is 3530 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.