5 Replies Latest reply on Sep 25, 2013 2:04 PM by philmodjunk

    Temporarily edit data in a layout?

    ErinO'Rourke

      Title

      Temporarily edit data in a layout?

      Post

           I have a script that someone else set up that pulls data into a layout, and at the end the data is fully modifiable while in Browse mode. Any changes made there are not permanent and don't affect the data in the records.

           I would like to set another script to have this capability, but don't know how. Is it done in the script itself, or in the layout?

        • 1. Re: Temporarily edit data in a layout?
          philmodjunk

               Sounds like their script copies the data into other fields and that these fields probably have global storage specified. Since you are editing a copy of the data, the edits will not affect the original unless you use a script to copy the edited data in the global fields back to the original field.

          • 2. Re: Temporarily edit data in a layout?
            ErinO'Rourke

                 Would that be difficult to do? I am fairly new to writing scripts.

            • 3. Re: Temporarily edit data in a layout?
              philmodjunk
                   

                        I am fairly new to writing scripts.

                   You better learn, setting up FileMaker solutions without creating scripts is like rowing a boat with only one oar. wink

                   You'll likely want to invest in some time and maybe $$ learning more about FileMaker Scripting. There are books, training materials and even free youtube videos on the subject.

                   It's more than a script, though, you first have to define the needed fields. Let's pretend that there is only one such field to edit--a text field. Doing this for more than one field is pretty easy to figure out from how to do it for one field.

                   1) Define a new text and use field options to set it up with global storage. For this example I'll put it in a table named "Globals" and Call it "EditText".

                   2) Create a layout and place Globals::EditText on that layout.

                   3) Now open Manage | Scripts, click new to start a new script and open the script editor. You'll add script steps by double clicking them from the list on the left side of the editor.

                   4) Create this simple two line script:

                   Set Field [Globals::EditText ; YourTable::TextFIeld ]
                   Go To Layout [ "Globals" (Globals) ]

                   5) On the Globals layout, add two buttons: Cancel and Save.

                   6) Set up Cancel to simply do this: Go to Layout ["name of your original layout goes here" (TableOfLayoutHere) ]

                   7) Set up Save with the perform script option and give it this script:

                   Go To Layout [ "NameOFOriginalLayoutHere" (TableNameHere) ]
                   Set Field [YourTable::TextFIeld ; Globals::EditText  ]
                    

                   You'll need to put your table and field names in place of mine in these scripts. And here's a useful tip about the Set Field step: When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

              • 4. Re: Temporarily edit data in a layout?
                ErinO'Rourke

                     Thanks, this is great. I've got it mostly working so far, except it's giving me the same data in every record in my "EditText" field. I know this has something to do with the global storage. How can I fix it?

                • 5. Re: Temporarily edit data in a layout?
                  philmodjunk

                       If the field has global storage, it should show the same data on every record. That's how a global field is intended to function. This method would be used to display the data from one record at a time for editing purposes so the fact that these fields show the same data on every record should not be a problem.