user1098767
user1098767

Reputation: 91

Filemaker Pro 11 Script - Add fields dynamically?

So we use FMP11 to do inventory management. I do price updates to our products 3 times a week and it would be nice to store our past cost values into a separate table for historical pricing. I know how I would go about doing most of it, but is it possible to create a new field that is labeled as today's date on the fly? So my headers would be labeled with that days date and the old pricing value from my other fields would be inserted.

Upvotes: 1

Views: 3047

Answers (2)

Michael Leishman
Michael Leishman

Reputation: 1

Create an new table (e.g. ArchivePricing) to hold the values you want to reference at a later date (e.g. ChangeDate, Price, Item, ItemID, etc.).

Create a new field in the current table called z|newprice - use this to type in your new pricing (you might do this on a list layout so you can easily change a bunch of prices).

Create a button that triggers a script that:

  1. creates a new record in the new ArchivePricing table and inserts the ItemID (thus creating a link to the original table) - this can be done using script parameters or setting a variable)... the script continues.

  2. uses the "set field" script step to insert info to this new record in the ArchivePricing table.

  3. uses the Get (CurrentDate) function to insert the date into the ChangeDate field (thus capturing the date the change was made).

  4. Before the script finishes be sure to use "set field" back in the original table to move the value in z|newprice field into your normal Price field. Do this at the end of the script and then commit record.

Upvotes: 0

Jesse Barnum
Jesse Barnum

Reputation: 6856

It is a bad idea to create new fields for the purpose you're describing. Create additional records instead, and do your report going from top to bottom instead of left to right.

That said, if you want to do it, you can using FileMaker Server Advanced with JDBC and the ALTER TABLE command.

Upvotes: 1

Related Questions