Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GetNthRecord ignoring the record number parameter in a script

Featured Replies

I'm using GetNthRecord within a script and increment the record number parameter. It seems to ignore the parameter and return the value from the field in the current active record. 

 

When I try this within the Data Viewer, I do NOT get this behavior and it shows the correct record. 

 

Any ideas?

Can you screenshot the script? This works correctly for me

 

Screen Shot 2016-02-16 at 9.22.02 am.png

  • Author

See Attached Image

GetNthrecord issue.JPG

I think your problem is in the way you are creating the list - am I correct in assuming you actually want a list of values from the found set for field $fieldname?

  • Author

Yea, I am trying to create a list of values from the found set. $value always seems to return the value from the field in the active record, not the Nth record. 

I've tried the custom functions and they don't seem to work correctly for me. 

I wrote an alternative script that goes to each individual record with GTR to build my list. That works.

The problem with your script is the way you use the $field variable. Instead of :

GetNthRecord ( $field ; $i )

do directly:

GetNthRecord ( GetField ( Get ( ScriptParameter ) ) ; $i )

 

  • Author

@comment That worked! Why would that make a difference? 

 

ALSO, this only works on values for the active table. If I try for a child table, I don't get any values.

Edited by GisMo

20 minutes ago, GisMo said:

Why would that make a difference? 

I wish I could give you a logical explanation, but I can't. It's a quirk stemming from the built-in confusion between field name (as text), a reference to a field, and a reference to the field's value.

 

22 minutes ago, GisMo said:

If I try for a child table, I don't get any values.

It works for me. What is you script parameter?

Note that your script, with its use of Get (FoundCount), is not geared for collecting values from the related set.

  • Author
8 minutes ago, comment said:

I wish I could give you a logical explanation, but I can't. It's a quirk stemming from the built-in confusion between field name (as text), a reference to a field, and a reference to the field's value.

 

It works for me. What is you script parameter?

Note that your script, with its use of Get (FoundCount), is not geared for collecting values from the related set.

My main table is for example Parent. So to be fully redundant, I'm passing in:

"Parent::Field1" and for current table as for the the child record.. I'm passing "Child::Field1" It's a one to one relationship

If it's a one-to-one relationship, then you will get at most one record in the list.

 

Edited by comment

  • Author

I also need to access the single related child field. Is this possible by GetNthRecord?

Just now, GisMo said:

I also need to access the single related child field.

What exactly does "also" means in this sentence? If you want to access another parent record and its related child record, then no, this is not possible. GetNthRecord() will allow you to make one hop, not two.

  • Author
1 hour ago, comment said:

What exactly does "also" means in this sentence? If you want to access another parent record and its related child record, then no, this is not possible. GetNthRecord() will allow you to make one hop, not two.

For Example. Two tables: Event and Instructor. 

InstructorID is a foreign Key in Event Table

I have a list view of event records based on the Event table. In that list view I include related field "Instructor Name". I want to use GetNthRecord on Instructor Name field.(Instructor::Instructor Name)

When referring to a related field, GetNthRecord() will get a value from one of the records related to the current record.  In your example, there is only one related record, so only GetNthRecord ( Instructor::Instructor Name ;1 ) will return a value - as will Instructor::Instructor Name.

  • Author
18 minutes ago, comment said:

When referring to a related field, GetNthRecord() will get a value from one of the records related to the current record.  In your example, there is only one related record, so only GetNthRecord ( Instructor::Instructor Name ;1 ) will return a value - as will Instructor::Instructor Name.

Putting in a number anything greater than 1 will return ?. It doesn't seem to retrieve Instructor Name from the Nth row in the event list. Is this expected? Is there a work around?

18 minutes ago, GisMo said:

Putting in a number anything greater than 1 will return ?

Well, yes, because there is only one related record. I seem to be saying the same thing all over again. There is no Instructor Name in any row of the event list. To get what you want, you will need to actually go from record to record (in the Events table) and put Instructor::Instructor Name.in the list (you won't need to use GetNthRecord() for this, because it's always in the first related record). Either that or make instructor name a calculation field in the Events table.

  • Author
9 minutes ago, comment said:

Well, yes, because there is only one related record. I seem to be saying the same thing all over again. There is no Instructor Name in any row of the event list. To get what you want, you will need to actually go from record to record (in the Events table) and put Instructor::Instructor Name.in the list (you won't need to use GetNthRecord() for this, because it's always in the first related record). Either that or make instructor name a calculation field in the Events table.

Thank you for the full clarification. That's what I am doing. Moving from record to record to get the related field.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.