Jump to content

Make a loop in Filemaker to copy data from one table to another


Recommended Posts

  • Newbies
Posted (edited)

I have the following problem, I don't know how to make this specific script work properly. Sorry if it is in spanish since it was made for spanish speakers in mind

  1. I have four tables, Factura, Detalle_Factura, Presupuesto y Detalle_Presupuesto
  2. The relationship of these tables is like this BcgaJ.png
  3. This is the layout in which I am trying to run the script. The portal below has the data from Detalle_Presupuesto and I need to pass that data from the portal to Detalle_Factura
     E2CQg.png
  4. This is the script I am trying to use but it only copies the first row of the portal row, I tried to do a loop too but it runs forever too x2LgE.png
  5. This is the layout I am trying to feed, the portal below has the data of Detalle_Factura and I need to feed it with the data of Detalle_Presupuesto PvORh.jpg
  6. I do have an empty presentation with the data of Detalle_Factura

In case this doesn't help, I am leaving a temp link with the database itself

Edited by Ocean West
added images inline.
Link to post
Share on other sites

First of all: is there a reason why you cannot import the records from the Detalle_Presupuesto table into the Detalle_Factura table? 

Even before that: do you really need two sets of data? Couldn't you simply flag the record in the parent table as a "factura"?


Now, I can't really follow your script. I think that if you really want to copy the related records in the Detalle_Presupuesto table, one by one, into the Detalle_Factura table, you should start by creating a found set of these records in a layout of the Detalle_Presupuesto table. This is easy to do using the Go to Related Record script step:

Go to Related Record [ Show only related records; From table: “Detalle_Presupuesto”; Using layout: "Detalle_Presupuesto" ]

Then just loop over these records using:

Go to Record/Request/Page [ Next; Exit after last ]

No counter is required for this.

Of course, this assumes you have already created a parent record in the Factura table and stored its unique ID in a variable, so that you can link the records you will create in the Detalle_Factura table to this record.


Finally, this caught my eye: you really don't want to use a random number as the $factura_id - certainly not a number drawn from a population of 500! Use either a serial number or a UUID.

Link to post
Share on other sites

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.