Basic script for creating a new related record in table2. (Easiest way to "auto-fill" data from table 1 is to link them in a relationship.)
#Perform script from layout based on Table1
Set Variable [$key ; value: Table1::PrimaryKeyField]
Go To Layout [Table2layout]
Set Field [Table2::ForeignKeyField ; $key]
Go To Layout [original layout]
This creates one new record in Table2 linked to the current Table1 record on the original layout. The auto-fill of data can take place automatically once the correct value is entered into table2's foreign key field.
There are two ways to set up your auto-fill. One way is a static link that physically copies data from table1. The other is a dynmaic link that simply refers to the fields in Table1. The best option for you depends on how you intend to use this data that you want to "auto fill". See the following link for a description and discussion of both options: