February 15, 20169 yr 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?
February 15, 20169 yr 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?
February 15, 20169 yr 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.
February 15, 20169 yr Yeah, I'd just loop the found set with Go To Next Record - List () is really for grabbing the related values (or repeating values) of a record http://www.filemaker.com/help/12/fmp/html/func_ref1.31.4.html Edited February 15, 20169 yr by webko
February 15, 20169 yr 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 )
February 15, 20169 yr 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 February 15, 20169 yr by GisMo
February 15, 20169 yr 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.
February 15, 20169 yr 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
February 16, 20169 yr If it's a one-to-one relationship, then you will get at most one record in the list. Edited February 16, 20169 yr by comment
February 16, 20169 yr Author I also need to access the single related child field. Is this possible by GetNthRecord?
February 16, 20169 yr 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.
February 16, 20169 yr 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)
February 16, 20169 yr 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.
February 16, 20169 yr 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?
February 16, 20169 yr 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.
February 16, 20169 yr 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