Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

Hello all,

Does anyone know what the basic script should be to add multiple new records into a table in my FM db?

The scenario is that I am in one layout viewing records and I want the option via a button to create multi records in another table in the same db.

I have tried many different ways to do it but to no avail!

I have created a little area on my initial layout which takes a number to represent how many records to create and the type of the record I create corresponds to the current record I have selected. So I basically want to take a reference field from this record and go to my other table and create 'n' number of new records using this reference field in one of fields.

This happens fine for one instance if i have a script like:

SetField[secondtable::product,firsttable::productID]

SetField[secondtable::ID,Max(secondtable::ID)+1)

But if i try to put this in a loop it just adds the 1 to my secondtable::ID but does not create multi new record instances.

I have tried to switch to my secondtable layout and using CreateRecord and I manage to create the records but only the first entry is filled in and the rest are blank. I have even navigated into the correct field before trying to insert data and watched it go in via the debugger, but still no joy! it stays blank.

I have spent many hours trying all sorts of different scipts for so any help would be really really appreciated.

Best Regards,

Bill

Posted

In the second table I would make the ID an auto-enterd serial number.

I would add a globals table with gProductID and gCounter.

SetField[globaltable::gProductID, firsttable::productID]

Go to layout 2 (table 2)

Set field [gCounter, 1]

Loop

Create new record

SetField[secondtable::product, globaltable::gproductID]

Set field [gCounter, gCounter + 1]

Exit loop if [gCounter > X]

End loop

Go to layout 1 (table 1)

Posted

There exist fast methods to create related records in a hurry, by letting a random number be the parentkey for the new record in a relation, having a turbulent birth where it gets it's foreingkey overwitten in just one scriptstep, that shift from hardly yet orphan to foster child. Methods does also exist with applescript that doubles the found set until the right number is created. But none of these is as fast as this way ...I've uploaded as template!

Enjoy

--sd

MakeInAJiff.zip

Posted

I've been toying with this teqnique for some years now, back in 5.5 didn't I go the repeating way, but instead some dwindling with a dynamic valuelist ...this was a rental management system where some itemID's for the contracts were say 4-5 alike (each having thier own serial numbers though) out of say 35. With many simultainiously contracts not starting or stopping the same days. These new features makes the developement so much cleaner!!!!

...but where the solution gets a little too complex (for my head at least) is to include recursive filestructures in this as well. But ideally should the system announce not posible if someone tries to book an entire PA setup, where some of the speakers allready are touring the world. Coolest would be a popup with suggestions for alternative posible setups (recursive sets)

--sd

Posted

I've been toying with this teqnique for some years now, back in 5.5 didn't I go the repeating way, but instead some dwindling with a dynamic valuelist ...

It was possible with 5 but would have needed to script the repeating field with a loop, which wasn't in this case effective, if you were to perform imports from the whole file. You should have looped through all records in the Base file before going to the other file. Kind of the same thing than looping in the external file and scripting record creation, so not very interresting compared to the new 7 approach.

But ideally should the system announce not posible if someone tries to book an entire PA setup, where some of the speakers allready are touring the world. Coolest would be a popup with suggestions for alternative posible setups (recursive sets)

Not sure I'm following you here. That's the interest of the related value list in fact I would think, and why having it dynamically concerted to a repeating field, through a calc, makes the final solutin so quick and simple.

What am I missing ?

--sd

This topic is 7307 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.