5 Replies Latest reply on Apr 21, 2009 3:15 PM by philmodjunk

    Reset fields on exit?

    trialuser1111

      Title

      Reset fields on exit?

      Post

      In my database I have a few fields for "temporary" use.  For example, as users select different records for inclusion in a report they just click "Include" and when they are finalizing a report there is a "Notes" field for making customized notes before PDF.  What I would like to be able to do is reset all those Notes fields to empty and reset all the Include values to "No" once a user exits FileMaker.  We will eventually be working off FileMaker Server, and I don't want people to get confused and start including the records that other people chose for their reports.

       

      Any suggestions? 

        • 1. Re: Reset fields on exit?
          philmodjunk
            

          Make the fields global fields if possible. (This is a field option on the storage tab.)

          Set all fields to their desired default values before uploading them to the server.

           

          With global fields in a network environment, each user gets a "virtual copy" of the fields that other clients won't see and which will revert back to there original values when the user quits FMP.

           

          Using check box fields to select different records will be a challenge. There are ways to populate a global field with ID values for each selected record. You'll need to do some work here if that's what you need to do.

           

          Otherwise, your user inputs may conflict before they ever close their session with the database.

           

          Consider, Client 1 selects 4 records by clicking a check box. client 2 selects 5 different records. Client 1 then performs a find for that checkbox value and gets all 9 records.

          • 2. Re: Reset fields on exit?
            trialuser1111
              
            This is exactly what I'm trying to avoid.  I didn't know about the behavior change to global fields in a network setup, so that's good to know.  Right now, I'm working with a single user license of FMP 10, prepping for a broader rollout supported by FMS, so I have no knowledge of those aspects.
            Is there a way to batch change the same field for a group of (or all) records?  I could perhaps add a "Done" button that triggers a Find + Replace and replaces any found text within the Notes field to " ".  Would that work?
            If so, I could add a similar Find + Replace that sets all "Yes" values to "No" in the Include? field and ask users to click another button when they are finished with their targeting.  It's not the most elegant solution, but it could be good enough for the time being.
             
            Thanks 

            PhilModJunk wrote: 

             

            Otherwise, your user inputs may conflict before they ever close their session with the database.

             

            Consider, Client 1 selects 4 records by clicking a check box. client 2 selects 5 different records. Client 1 then performs a find for that checkbox value and gets all 9 records.


             

            • 3. Re: Reset fields on exit?
              philmodjunk
                
              trialuser1111 wrote:

              Is there a way to batch change the same field for a group of (or all) records?  I could perhaps add a "Done" button that triggers a Find + Replace and replaces any found text within the Notes field to " ".  Would that work?

              Not a good idea read my previous post again for the reason why. There's method called "Replace Field Contents" that will do what you want, but it's not a good idea for the situation you describe. Use global fields for all your "notes" type fields.

               

              There's a second issue that makes these kind of batch updates dangerous in networked environments.

              Filemaker is designed to keep two users from editing the same record at the same time. If client 1 clicks into a field of record 1, when client 2 clicks into a field of the same record and tries to modify it, you'll get an error message telling you that another user has "locked" the record. This is to avoid the confusion that would happen if two or more users tried to edit the same record at the same time.

               

              In the case of "batch" type updates, if one or more records are being edited by another user, those locked records won't be updated. Instead you get a message that "2 records could not be modified..." Not only did they not get changed, but the message doesn't tell you WHICH records did not get changed.

              • 4. Re: Reset fields on exit?
                trialuser1111
                  

                To my understanding, global fields apply a single value to all records.  I use the Notes field for a customized sentence or two for each record chosen for inclusion (which in turn, must be unique for each record, right?)

                 

                I see what you're saying about Find + Replace though.  That's definitely not a viable solution. 

                • 5. Re: Reset fields on exit?
                  philmodjunk
                    
                  trialuser1111 wrote:

                  To my understanding, global fields apply a single value to all records.  I use the Notes field for a customized sentence or two for each record chosen for inclusion (which in turn, must be unique for each record, right?)

                   

                  In that case simple text fields may work for them. It depends on how likely two users will be attempting to edit the same records simultaneously. If the records pretty much belong to just one user, then collisions may be rare and you may be able to live with that.

                   

                  Otherwise, you'll need to store your notes so that they relate to the correct records but are not accessible to other users.

                  Here's one method:

                   

                  Define a global text field in your main table, gAccount.

                  When the user first opens a file, use file options to trigger a script:

                   

                  Set Field [gAccount, Get(AccountName)]  //I'm assuming each user has a unique account name

                   

                  Now create a new table, "Notes," with the following fields:

                  AccountName (text)

                  IDkey (number)

                  Note (text)

                  Selected (text)

                   

                  Create a relationship linking, MainTable::ID--=--Notes::IDkey AND MainTable::gAccount--=--Notes::AccountName

                  Enable the create related record option for the Notes side of this relationship.

                   

                  Now you can place Notes::Note and Notes::Selected (format as your check box) and only the current user will see their notes and selections.

                   

                  To find all selected records, you'll need to search your layout, but specify your account name in the Notes::AccountName field as well as "Selected" in the Notes::Selected field to find just your selected records. (It's best to script this.)

                   

                  To clear the Note and Selected fields, you can now use "Replace Field Contents" (This is NOT the same and Find/replace) in a script.

                  Replace Field Contents [No Dialog; Notes::Note; ""]

                  Replace Field Contents [No Dialog; Notes::Selected; ""]

                   

                  Use File Options to trigger this script when the file is closed.