Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages

Shopping Cart
Shopping Cart


Free Newsletter


Privacy Policy

FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.


 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

GetNthRecordSet ( fieldName ; recordNumStart ; recordNumEnd )

Rate this function:  

  Average rating: 3.9  (64 votes)
  Discuss this Custom Function

Jonathan Mickelson, Thought Deveopment Corp.

Calculates a return delimited and sorted, values list from related, or local, field data.

Sample Input:
GetNthRecordSet ( Children::Name ; 1 ; "" ) == where 3 children's names exist, unsorted.

GetNthRecordSet ( FirstName ; 2 ; 4 ) == where 5 records in found set sorted by FirstName
Sample Output:


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed


Creates a return delimited value list of the values from the field specified, beginning with the recordNumStart and ending with recordNumEnd. The resultant value list's scope and sort are determined by the source field; thus for local fields the sort is determined by the current sort of records in the found set, for related fields it is by the relationship sort.

This single Custom Function can replace Copy All primary keys of a foundset practice as well as the use of ValueListItems() to create a value list of related values for other relationships.


fieldName - Any local field, related field, or an expression that returns a field. NOTE: For repeating fields this Custom function will only see the first repetition, per record. Also, Globals will behave similarly and the global will be display once for each record.

recordNumStart - The record number from which you want to begin getting data. A null ("") or 0 value will set the start at the first record.

recordNumEnd - The record number after which you want to stop getting data. A null ("") or 0 value will evaluate until the the last record is reached. This parameter is inclusive, thus 10 will end the value list with the 10th record, including the contents of the field in that record.

Output Format:

A return delimited text value list of the the contents of fieldName dictated by the provided start and end record numbers.
Note: The result of GetNthRecordSet() will not be updated when the record referred to by GetNthRecordSet() is a record other than the one in which the calculation is currently being evaluated.


Given the following related Field data for Children::FirstNames:
Related Record 1 = Jimmy
Related Record 2 = Suzzie
Related Record 3 = Johnny
Related Record 4 = Dweezle

GetNthRecordSet ( Children::FirstNames ; 1 ; 3 ) = Jimmy¶Suzzie¶Johnny

GetNthRecordSet ( ParentFirstName ; "" ; "" ) = Value list of all parent names in current found set, in sort order

GetNthRecordSet ( ParentFirstName ; 30 ; "" ) = Value list beginning with the 30th parent name till the last record in current found set, in sort order.

Special Thanks: To Ray Cologon, for refining the IsValid test instead of a cumbersome case test and his ubiquitously simplified code ideas!

Note: these functions are not guaranteed or supported by Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it


5 most recent comments | Show all 10 comments

In my experience what you describe is a common occurrence with the "recover" command and custom functions... there are a large number of threads outlining the recover report saying this about a miscellaneous Custom Function or two in a file, even clean new files with new empty CF's! A Google search on this text will outline other people's similar experiences.

I'm pretty certain it's nothing to do with this specific calculation.

I've seen this in my own files with random Custom Functions too, what I usually do is remove the calc text in the CF, (though not delete the CF entry/name, so it doesn't break links) and replace it with "" and save my file out, compress/re-write the file as a copy or clone and then try the recover to see if it's actually still reporting this. Then I paste the function back in.

This doesn't usually DO anything, but it makes me feel better when the recover command erroneously says "this formula has been changed"... Someday, FileMaker will explain this or fix this behavior so we "Recover" can focus on actual problems in the files.

Best of luck!!!

Jonathan, Los Angeles
August 01, 2011 11:20am

work not by paste in fm11
(need operator)

Bonino, CH Bern
July 05, 2014 3:45am

Hi Bonino,

I just opened a new file, copied from the website and pasted it in successfully. The message you saw was most likely one due to the three parameters needing to be named, and/or the name of the function needing to be the same (as it's a recursively self-referencing function).

I'd also suggest re-checking that the copy grabbed all the text, sometimes a partial copy can mess up the calculation by missing a parenthesis.

I hope it works out for you!

Jonathan, Los Angeles
July 05, 2014 5:18pm

Be really nice if this could evolve so that it could return from text fields any chosen string!!!

jLT StructuresFromSilence, Kendv,IN USA
March 27, 2015 3:47pm

made the function twice as fast - the original tests for validity, then recursively calls itself, getting the value:

// GetNthRecordSet ( fieldName ; recordNumStart ; recordNumEnd )
// version 1.1, Jonathan Mickelson, Thought Deveopment Corp,

Get return-delimited list of values for the specified field from the found set.

Uses the same sort order as the records.


1.1 - 2017-12-05 ( eshagdar ): 2x speed improvement - loop over the records ONCE instead of testing for validity, then getting the value. added formatting. added documentation. converted case into if functions. declare end var inside of the let to simply test below. use existing params instead of declaring new variables.
1.0 - 20xx-xx-xx ( xxxxx ): brought in.
0.0 - 20xx-xx-xx ( jmickelson ): posted on

Let ( [
recordNumStart = If ( recordNumStart < 1 ;
1 ;
) ;
recordNumEnd = If ( IsEmpty ( recordNumEnd ) or recordNumEnd = 0;
Get ( FoundCount );
thisVal = If ( IsValid ( GetNthRecord ( fieldName ; recordNumStart ) ) ; /* this limits "?" result on empty related records */
GetNthRecord ( fieldName ; recordNumStart );
) ;
nextStart = recordNumStart + 1
] ;

thisVal &
If ( nextStart ≤ recordNumEnd;
"¶" & GetNthRecordSet ( fieldName ; nextStart ; recordNumEnd ) ;

Erik Shagdar, New York
December 05, 2017 10:21am

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 1 + 5 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. interpolation (y1; y2; y3; x1; x2; x3; x1y1; x2y1; x1y2; x2y2; rnd)
  (Sat, May 19, 3:55am)
2. @JSONFormatElements ( json )
  (Tue, May 15, 3:31am)
3. WindowNamesAll ( dbNames ; excludeCurrentWindow )
  (Sat, May 12, 11:34am)
4. RandomChoiceFromList ( values ; required )
  (Wed, May 02, 6:35am)
5. @JSONFormatElements ( json )
  (Fri, Apr 27, 7:31am)
6. MBS-OCR ( language ; Image )
  (Mon, Apr 23, 1:48pm)
7. MBS_Image_Rotate ( Picture ; rotation )
  (Mon, Apr 23, 1:27pm)
8. UnQuote ( string )
  (Tue, Apr 10, 12:34pm)

RSS Feed of Custom Functions