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 - Show more from this author
Linear Blue http://www.linearblue.com |
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, 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'. |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.