Jump to content

GetNthRecord ignoring the record number parameter in a script


This topic is 2985 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 2985 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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