GetNthRecord - portal and with condition
So, I have a layout (SHIFT) , with an unique id, with a portal (EQUIPMENT RECORDS).
I have a button that triggers a script that fills the portal rows with the equipment's names, so that i can fill the rest with other information. Each equipment has several fields, including: KM1 (km that the machine ended up in the previous record), KM2 (km that the machine ended up at the end of the shift), KM (result from subtraction).
So i would like to fill "km1" with the value "km" from the previous record, for THAT equipment.
I've created a relationship with the equipments table to itself: KM1 = KM2, ID EQUIPMENT RECORDS dif ID EQUIPMENT RECORDS, and also EQUIPMENT = EQUIPMENT.
I've based on a script i've found online and changed: "Get_From_last_Record::Company" to "Equipments:KM1" and "Name" to "KM2" ('cause it is the next field, after KM1)
This only returns "?". Obviously, the script doesn''t have any mention to the equipment correspondence, but could retrieve any value... and it doesn't.
Thanks in advance.