May 21, 201510 yr 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 May 21, 201510 yr by fmpfan
May 21, 201510 yr Author 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?
May 21, 201510 yr 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.
May 21, 201510 yr 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 May 21, 201510 yr by LaRetta added ( Layouts > Layout Setup > Show Records From )
May 21, 201510 yr ... 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 … Edited May 21, 201510 yr by eos Clarified calculation "field"
May 21, 201510 yr 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 May 21, 201510 yr by LaRetta
May 21, 201510 yr 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 May 21, 201510 yr by comment
Create an account or sign in to comment