Please confirm whether I have your relationships correct:
Customers::CustomerID = Machines::CustomerID
Machines::MachineID = Service::MachineID
If so, you may not need to add that invisible button. In layout mode, you can select all the fields in your portal row and use Button Setup... to make the group of fields into a button object.
The button need only perform this script:
Set Variable [ $MachineID ; value: Machines::MachineID
Go To Layout ["Service" (Service) ]
Set Field [Service::MachineID ; $MachineID]
All other data from the Machine and Customer tables will be accessible to this new record via the relationships once you have entered the correct value in the MachineID field.
Phil, your a diamond!!
Looking at your script I can see I was sooo close to getting it right!
I've tried to adapt the script to work on a dropdown box but not having much luck, Im using customer name in a dropdown box and want to go through to customer orders and open a new record from the name in the dropdown box and put the relevent customer information in the new record ie address etc
Using the customer name might be a problem. You can easily have two or more customers with the same name--even if your customers are companies. A value selected from a drop down list can be used with either Go TO Related Records (IF you have the appropriate relationship that usees the drop down list field as a match field) or a scripted find. If you use a name for this, make sure to include code that can detect the fact that records with the same name exist and that then presents information to the users so that they can further refine their choice.
Here's a thread set up to share many examples of using a global field with a script to perform a find: Scripted Find Examples
And here's a demo file that uses an auto-complete enabled value list of names for selecting a record by name yet it establishes a link based on the ID number with code set up to handle cases with duplicate names:
FileMaker 12 users: https://dl.dropbox.com/u/78737945/SimpleNameLookupDemo.fmp12
Pre FileMaker 12 Users: https://dl.dropbox.com/u/78737945/SimpleNameLookupDemo.fp7