How to display related records in an HTML view

How to display related records in an HTML view


My view currently displays one record from one table.
 
x  =  Purchase_Order  [ID == input.PurchaseOrderId.toLong()];
 
where Vendor_Account is a field in Purchase_Order
 
I want to include other records from tables that are related via look-up fields on the original form but the only fields that appear in the script builder window as a collection variable is the name of the lookup field, not the id of the corresponding record.
 
ex.
 
y = Vendor_Account [ID == x.Vendor_Account];
 
but of course that doesn't work because x.Vendor_Account is a string (in this case the account name) from the look-up field and not the actual ID (which is what is actually stored in the the Purchase Order table). So basically I don't know how to where zoho stores this id and how to access it.
 
Either I shouldn't be fetching the records, or I'm doing so incorrectly need to know a way to convert the stored name to the id. 
 
Thanks -Beth