Software Venture Consulting

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

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


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:  

RatingRatingRatingRatingRating
  Average rating: 4.0  (63 votes)
  Discuss this Custom Function

Jonathan Mickelson, Thought Deveopment Corp.
http://thought-dev.com

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:
"Jimmy¶Suzzie¶Johnny"


"Luther¶Mike¶Suzzie"


 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

Description:

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.

Parameters:

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.

Examples:

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 BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

Discuss:

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

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

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, http://thought-dev.com

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


NOTE:
Uses the same sort order as the records.


WARNING:
Recursive


HISTORY:
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 http://www.briandunning.com/cf/439
*/


Let ( [
recordNumStart = If ( recordNumStart < 1 ;
1 ;
recordNumStart
) ;
recordNumEnd = If ( IsEmpty ( recordNumEnd ) or recordNumEnd = 0;
Get ( FoundCount );
recordNumEnd
);
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:
City/Location:
Comment:
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 + 7 =
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. NumberToHexadecimal(NumberValue)
  (Fri, Dec 08, 8:54am)
2. Get_BaseTable
  (Thu, Dec 07, 4:27pm)
3. JSONCreateVarsFromKeys ( json ; namespace )
  (Wed, Dec 06, 8:21pm)
4. GetTableNzme ( field )
  (Tue, Dec 05, 9:16pm)
5. TimeFormatAsText ( theTime )
  (Mon, Nov 13, 1:59pm)
6. ParseWebValueList( text )
  (Thu, Nov 02, 9:52am)
7. SVG_HTML_to_Text ( _svg_text ; _orig_text ;
  (Wed, Oct 25, 4:17am)
8. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)

RSS Feed of Custom Functions