referencing a multiply linked field in Deluge script - how many link levels can I go?

referencing a multiply linked field in Deluge script - how many link levels can I go?

I am working in a stateless form.  I am trying to reference a field that has been linked through regular forms via 'lookup fields'.  This is what I have done and I believe I got this code from an earlier inquiry of public example app:

Here is only an example to illustrate what I want to do.  

The user enters a unique customer ID (not the record ID) in a stateless form field.  
And suppose the customer has earlier selected one Product in a lookup table on the Customer form.  
And there is a Product form that has product attributes including a lookup table for the Rep for the Product.
The Rep has attributes that include, among other things, Email_addr.

This script in a button press is designed to populate the other stateless fields with appropriate data.

myvar  =  Customer  [Customer_ID = input.Cust_ID];  
// myvar becomes a recordset of one matching record
//Customer_ID is a field in the Customer form

input.name= myvar.name;  // populates the customer name field
input.Product_name=myvar.Product.P_name; // populates the product name field

Now here comes the problem.  I want to go one level further and reference the email for the Rep

input.rep = myvar.Product.Rep.Email_addr;

But when I click 'save', the code checker turns red and just says 'null'.

Where have I gone wrong or how can I do what I want to do here?  Perhaps create an intermediate recordset for the Product or Rep?  I will try this . . . but meanwhile . . . your comments please?

** UPDATE ** 

I tried creating an intermediate dataset as follows, but this was not allowed:

myvar2=myvar.Product[P_name=="sample"];

message: Encountered '['  was expecting one of ";"  . . . "*" . . .

Cheers,

DJ