Brian Dunning's FileMaker Custom Functions

Portal_Row_Number ( ID ; Field ; Counter )

Find a record number from its position in a portal row.

  Average rating: 4.1 (31 votes) Log in to vote

Simon Ward   Simon Ward
Linear Blue
http://www.linearblue.com

Share on Facebook Share on Twitter

  Sample input:
Portal_Row_Number ( 2 ; Related::_kp_Field ; 1 )
  Sample output:
6

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This calculation will display which portal row a record is based on a Pirmary table and Line items table. There must be a relationsip between the Line Items table and its self based on the Primary Table Key. i.e each line item will display the same portal that would be seen from the Primary record. In the Calculation the Related::_kp_Field is over this self relationship.

 

Comments

John Buckingham   John Buckingham, microGuidance
Nov 29, 2016
Hi Simon

Thank you for posting this CF. I couldn't get it to work in FM14 but your concept was so elegant that I've slightly modified the code and it seems to work for me.

The changes I've made are; including totalRows in the parameter set (so it is determined once rather than for each iteration) and including the 'getField' function in the getNthRecord element.

So, my version of your CF is now:

Case (

Counter > totalRows ; "0" ;

ID = GetNthRecord ( GetField ( Field ) ; Counter ) ; Counter ;

Portal_Row_Number ( ID ; Field ; totalRows ; Counter + 1 )

)

I couldn't understand the part of the description regarding the requirement for the TO relationship definition, but the modified code seems (so far!) to work on any portal without any further TO being required. All I send the CF is; 'getfield ( the PrimaryKey field )' for the current portal row, 'getfieldname ( PrimaryKey field)', the number of rows of the current portal relationship, & '1'.
 

Log in to post comments.

 

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

Under construction. Email me your wish list for improvements.