2 Replies Latest reply on Mar 9, 2011 1:17 AM by james.gould

    Set Field Speed

    james.gould

      Title

      Set Field Speed

      Post

      When scripting there are many different ways of 'setting' a field:

      • Set Field (and variations)
      • Insert Text/Calculated result etc...
      • Replace Field Contents
      • Copy/Paste (I gather this is here from filemaker's earlier legacy for backwards compatibility and it is bad practice to use this now)

      Our client has asked for an 'apply to all' button which will copy a given date and the contents of two other global fields into a set of given records, usually less than 50 - however it will still have to loop through these records.Given that some of their staff will be accessing via internet connections (but still using FMP11) speed/efficiency between the server and the client are of key concern. I would be very grateful if anybody could advice me on the fastest way of putting the date into the field...

      At the moment I am storing the values as variables (so the system doesn't have to look at the relationship diagram every time it picks up the values from the field - I'm hoping this saves some time), going to a layout and creating the found set, freezing the window and looping through setting the 3 fields (using the Set Field script step). I have a suspicion that the suggestion might be to try all the variations of the Set Field step my self, but thought it might be worth asking anyway!

        • 1. Re: Set Field Speed
          philmodjunk

          Replace Field Contents will avoid the loop and I think it's the fastest option also, but you have another issue you'll need to handle:

          Given that some of their staff will be accessing via internet connections...

          If they are editing one of the records you are attempting to update, they will have locked the record and this will keep both a looping script with set field and a Replace Field Contents operation from updating the locked record. (Only one user is allowed to edit a record at one time.)

          For this reason, it's often much safer to postpone such "batch updates" to points in time when there are no other users accessing the database. If there is even the slightest chance that a user may be editing a record you want to update, you'll need to add code that checks for the record lock or the error code generated by the lock and then either processes the updates for those locked records at a later time or at least presents you with a report that lists the locked records.

          • 2. Re: Set Field Speed
            james.gould

            Thanks! I didn't realize that's what replace field contents does - I presumed it was an alternative/superseded script step that with a similar function to 'Set Field'... And the advice about checking for locked records will be invaluable! I think the client will be more comfortable within instant results, but I will suggest that it's best to perform this action when usage is likely to be low.