Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Copying the record id to be pasted in another file


Recommended Posts

I am trying to copy a record id of my parent file so I can paste it in another file to be used as its record id for new related records. So far the pasting hasn't worked and the set field command doesn't do anything either.


It seems as soon as the script leaves the parent file to attempt to paste or use the set field commands, the record id to be pasted disappears. I'm also using data viewer to see at what point the data appears.


A relationship do exist between the two of them but still its not working. Any assistance would be appreciated.

Link to comment
Share on other sites

I can't say what you're not doing right. But generally a script to create a new related record in version 8 would run like this


#you're in the main table

set variable [$ID ; MainTable::MainID ]

freeze window

go to layout [ChildTable]

new record / request

set field [ChildTable::MainID ; $ID ]

go to layout [original]


If there is a portal on the main layout, it should now be + one portal row.



Link to comment
Share on other sites

oh I see you're speaking about "another file" is this correct? if so, why? my script is for related tables within the same file.


if you have the file reference in place, you can call a secondary script in the related file.


so in main:


set variable [$ID ; MainTable::MainID ]

open file [Childfile, hidden]

perform script [external; "AddRecord"]

go to field [ ]



in the child file, the script "AddRecord"


new record/request

set field [childfile::mainID; $ID]




Link to comment
Share on other sites

Since variables are file-specific, you'll either need to use a global field instead, or send the ID as a script parameter. I like the script parameter idea, as it doesn't require another field and it makes the creation script in the second file more modular.


The script parameter thing would look like:


Commit Records/Requests []

Perform Script [external; "AddRecord"; parameter: table::ID ]


Then in the child file, the script "AddRecord":


New record/request

Set Field [ childfile::mainID; get(scriptparameter) ]

Link to comment
Share on other sites

What they said.


The technique you actually asked about in the OP is how we used to connect related files in FileMaker 2 (which wasn't really relational, you had to cheat a lot).


Generally speaking, though, beginning with FileMaker 3, you don't have to use "Copy" or "Paste" just to navigate or do scripted Finds and whatnot. And it's generally best not to use "Copy" in scripts because it wrecks the user's clipboard. Once FileMaker got to the point that we didn't have to, it makes sense not to use Copy and Paste RecordID from one table to another so as to make a related record.


But your thinking isn't wrong, it would work, and as I said, it's how we did it back in the dim dark days. The scrips would look like this:


=== Make Related Record, script in MainFile.fm ===


Copy [select, RecordID]

Perform Script [Remote, in file "Otherfile.fm", "New Record"]



=== New Record script in Otherfile ===


New Record/Request

Paste [RecordID]

Go to Field [1st DataEntryField]

Link to comment
Share on other sites


  • Create New...

Important Information

Terms of Use