7 Replies Latest reply on Sep 14, 2014 9:27 AM by BruceRobertson

    Set Field Name Script



      Set Field Name Script


      Hi All,

      I'm trying to create a script (a new mountain I'm trying to climb) that is triggered when a button on Layout A is pressed.  That script should take the user to Layout B, create a new record then set about four or five fields on Layout B to their exact same value and field name as on Layout A.

      So the Go To Layout part is easy; so is the create record.  However, when I do the Set Field Name (LayoutA::Field1; LayoutB::Field1) I get nothing at all on Layout B.  I've even tried the inverse just in case.

      I've got to believe this is something to do with what record is active and not the Set Field function.  Any guidance is appreciated!

        • 1. Re: Set Field Name Script

          It would be helpful to describe in more meaningful language what you are trying to do, and especially - why you think you need to duplicate information.

          (Not field A, field B etc)

          In general, this is why we have relational databases; so you do NOT have have duplicate values. Instead, you have one instance of the values and a relationship that lets you see those values in other contexts.

          But - to more directly answer your question, it DOES have something to do with set field; but also with capturing the original values before you change context. Example:

          Set Variable [ $firstname; contacts::firstName]

          Set Variable [ $lastName; contacts::LastName]

          Go to layout Book Club members

          New record

          Set field [ Member::firstName; $firstName]

          Set field [ Member::LastName; $lastName]

          • 2. Re: Set Field Name Script

            Okay, the need for duplicate information comes from Layout B not ALWAYS needing to be filled with the fields from Layout A.  In fact a lot of the time it won't be used but having those four (for the moment) fields pre-populate is a great way to identify which record the other data (input on Layout B) belongs to.  For whatever its worth, Layout B is purely a table whose data are exported to an Excel file which is then used to populate the merge fields in a Word Doc and elsewhere in the program, those fields aren't used.  Unfortunately, Word for Mac 2011 is not compatible with FMP13... would have been good to know ahead of time but whatever.

            All that said, I tried using the Set Variable option you recommend and it's working perfectly.  I did elect to use double $$ so that it was global (can't hurt!) and because more $$ is better than $.  (Grin)

            • 3. Re: Set Field Name Script

              It is also possible that instead of copying over the names, you may need to link the new record in layout B's table to the current record shown on Layout A's table.

              Once the link is established, you can access all data in that record on Layout A, either to copy it into fields of the new record or to display it on the layout as though it had been copied.

              For more on the copy vs. link process: Auto Fill

              Caulkins Consulting, Home of Adventures In FileMaking
              • 4. Re: Set Field Name Script

                Yeah, and the more I look at it the more I can see the purpose in linking these two.  Not for the immediate purpose so much as the down-the-road record keeping one.  I'm new to this though and starting simple is where my playground is.

                • 5. Re: Set Field Name Script

                  Clicked the wrong "best answer."  Don't know how to change it.  Bruce Robertson wins this round though.  With Phil Mod Junk coming in a close second for philosophical reasons.

                  • 6. Re: Set Field Name Script

                    Okay, the need for duplicate information comes from Layout B not ALWAYS needing to be filled with the fields from Layout A.

                    That simply means that you need to link SOME records from Layout A's table to a Record in Layout B's. It does not mean that you need to copy over the data.

                    • 7. Re: Set Field Name Script

                      Global variables are useful in their way but they CAN hurt and should generally be avoided, in favor of script variables.

                      Gee, when did I last set that $$value? Is that really the current value? Did Script X set it or script Y? Did I set that an hour ago? Oh wow man I don't remember!

                      Script variables clear themselves after that script runs.

                      Two other important and related features to learn about are script parameters and script results.