June 27, 200421 yr 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. Thanks!!!
June 27, 200421 yr 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, Dana
June 29, 200421 yr Author 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! Thanks!
Create an account or sign in to comment