Jump to content

Automatically create new related files


This topic is 7101 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have two related tables where each record in table A has exactly two related records in table B. Is there a way to script table A such that whenever a new record is created, two related records are simultaniously created in table B? I would rather not have to rely on buttons to start scripts, etc. if I can. FM makes it easy to automatically delete related records but it's the creation I'm struggling with.

There is much more to this solution than I am explaining but this is the sticking point in my progress.


Link to comment
Share on other sites

Without using plugins, there really isn't a way to trigger a script on record creation. If you had FM7, you could use the example free plugin that comes with FM7 Dev and is posted at databasepros.com.

If you use a portal to create related records, The script itself would look something like:

New Record/Request //This creates the parent record

Go to portal row[last] //

Set Field [whatever you want it to be]//this will create the related record

Repeat the last two steps for as many records as you want... If you want alot, consider using a loop to to this.

You could also change the script to store the primary key in a global, and then use that in a script in the related table to set the foreign key value.

Hope this helps,


Link to comment
Share on other sites

Thank you, that portal script is good to know.

It occurs to me that I will only be accessing table B for reports (not often) so I could create a startup script that loops through table A and creates the necessary related records in table B. It would cause a logjam while processing but it will be up to date when I need it.

Any other ideas would be greatly appreciated!


Link to comment
Share on other sites

This topic is 7101 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.