2 Replies Latest reply on Jun 20, 2012 5:03 PM by pauhana658

    Newbie scripting issue - change value in field based on value in related field



      Newbie scripting issue - change value in field based on value in related field


      Coming from 4D, I'm at sea as to how scripting works in FileMaker, perhaps due to the differences in the names of script "steps" (?). I can't figure out what steps are necessary to perform the desired actions. I keep trying to find FileMaker steps that are equivalent to known 4D commands  and I'm getting nowhere. Clearly, the two programs have very different scripting structures.

      Basically, I have a set of related tables, and I'd like to set the values of certain fields in a portal based on a value I've entered in another field in that portal. It involves looking up the values in related tables.

      Current table: Invoices, with portal for Invoice Details table; client value in Invoices table is set from Clients related table.

      In the Invoice Details portal, I have fields for Category, units, rate, and subtotal; the Cagetory field is a popup filled with values from the Category table. I want to select a value from the Category popup and then automatically fill in the Rate. The Rate value would come from a Rates table related to the Client record that is related to the current Invoice. The script should look something like this in plain English:

      Go to the related record in the Clients table

      Find the field in the related Rates table that matches the value selected from the popup

      Set the value of the field Rates in Invoice Details to the value found in the related record in the Rates Table


      I'd think this kind of thing would be basic stuff, and I'm sure that FileMaker can do it, but I don't know how to write a script that does it. I have the script reference, I just need to know which steps I should be looking at. Can someone give this FileMaker newbie a few hints? 




        • 1. Re: Newbie scripting issue - change value in field based on value in related field

          You don't need to write a script.  4D basically makes or lets you create relationships on the fly as you need them.  Filemaker expects the relationship to be predefined.  If you had two tables, Job Table and Rates Table, where the Rates table has a list of rates for each task.  Say Copywriting, Editing, etc.  The Jobs Table holds data about the job, including what task was being done.

          Create a relationship between the Jobs Table and the Rates Table linking them by TaskName.

          For the other fields (such as Rate) that you want to auto-populate into the Jobs Table, go to the field's definition in the Job Table and set it to auto-enter by Lookup (or by calculation) the value of the rate from that relationship you just created.

          As you choose a different value for the task it will auto-insert values from the matching Rates Table record.

          • 2. Re: Newbie scripting issue - change value in field based on value in related field

            Yep, after reading the documentation and clicking through lots n' lots of dialog boxes (Filemaker does love its dialog boxes, doesn't it?), I figured out how to do this. 4D does this kind of thing more straightforwardly if you know your code, but Filemaker does quite a bit without resorting to coding. It will take some time to get used to Filemaker's ways (and dialog boxes), but good to know that light does, indeed, exist at the end of this database tunnel. After a week's hiatus, I'll be doing some more drilling today.