How is the workers table and salary table linked? How would you want the new salary table record created? Would there be multiple workers related to the same salary record or vice versa?
The workers table and salary table linked using __pkworkerid ( using serial number ) to _fksalaryid . I want the new salary table created after creating new records of worker in workers table . There will be multiple salary records related to one workers .
If [ not SalaryTable::_fkworkerid //assuming that this field is of type number here]
Set Variable [$WorkerID ; value ; Workers::__pkworkerid ]
Go to Layout [Salary]
Set Field [Salaray::_fkworkerid ; $WorkerID}
Go To Related Record...
Where should i put this script? in a new record button or 'onlayoutload'
Neither, as this only creates a new record if one does not already exist.
You indicated that you couldn't use Go To Related Record when there wasn't a related salary record. With the above script, you now can.
A new salary record button on the workers layout could use the code between the If and the Else to create a new related record in salary any time you need one.
Please note that you can do this without any script at all.
If you enable "allow creation of records via this relationship" for the salaray table in the workers to salaries relationship, you can put a portal to salaries directly on your Workers layout and then can add new salary records whenever you need to just by entering data into the bottom blank row of the portal.