About This File
FileMaker requires you to be on a layout or use the relationship to establish context in order to create a record in a given table.
You could us a plugin that uses SQL to create a record in a table or you can use this technique.
It's very simple.
From the Source table you export field context the primary ID field to a text file. I choose to export it to the temporary directory path.
Then you immediately import that same file in to the target table --- That is right you do not need to be on a layout that tied to the base table occurrence -- you could be on any unrelated table.
On import you adjust the field map to import the value of the text file into the foreign key field of the target table.
In this example it is a different take on a Note Log. You can type into a global field and on exit it will trigger the script to export and import that one record then clears the global field. Data entry options in the note field in the target table is defined to use the value stored in the global field.
you could choose to do things more elaborate like either exporting more columns of data by building a tab separated values to a global field and export that and import it into any table matching field names (provided your first row includes field names - and you omit them on data entry )
OR you can set variables to the desired values and then on the target table set the data entry options to the corresponding variables.
And if you choose to include data other then the ID fields you may wish to also delete the file you can do this by un checking the Specify Field checkbox on the Export Field Contents script step.
Now with all this established I realized that this technique will not work on FMGo because the exporting of the file.
So there is also another script layout and table that will in essence do the same thing and it only needs to IMPORT one
record from a temp table and doesn't need to export. I actually like this method better; but kept both concepts in the
sample file for you to explore.
What's New in Version v2
- v2 changed a mistake in the field map