If your variable is named $$GlobalVariable, use:
Set FIeld [ Tx::PTIdNumber FK ; $$GlobalVariable ]
When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.
Although I think I understand the actual results dont support that. The button does open a new record but doesnt populate the field with the id number. Here is a shot of the two scripts
Whoops, i caught the setFieldByName thing. It works and you are making my day better every time we speak!!!
I would guess that the left hand script is not being performed prior to the right hand script being performed.
Try putting all these steps into a single script with the left hand script set up as the first two lines of the script and the right hand script steps listed after them. Then run the script from the PT layout and see what happens.
And the go to field step may be removed from the script as it is not needed.
I seem to recall an earlier thread where you asked about this. If memory serves correct (and after 50,000+ comments posted here, it may not be correct), I described using a an auto-enter calculation setup on the fk field--which is not the method your are implementing here.
If you are using a script to create the new record, using a single script performed by a button click makes more sense.
I like the all one button idea. It would be from pt layout:
set the global variable
assign global variable to field