8 Replies Latest reply on Oct 9, 2009 10:33 AM by comment_1

    How would filemaker handle this situation

    grinch

      Title

      How would filemaker handle this situation

      Post

      I have a database with a global field that contains a number.

       

      This field is displayed on a layout.

       

      There is a script that increments this field by 1.

       

      While one user is viewing a record, and when he is viewing the record, a second user from a different record runs the script to increment the number in the global field.   When will the first user see the new number in the global field?  What happens if the first user runs the script to increment before he sees the new number in the global field.

       

      Thanks

      Chris

       

        • 1. Re: How would filemaker handle this situation
          comment_1
            

          grinch wrote:

          a second user from a different record runs the script to increment the number in the global field.   When will the first user see the new number in the global field?


          Never. Each user has their own set of global field values. These values last for the duration of the session. The next time the user logs in, the globals will hold the initial values - i.e. the values set when the file was last opened in single-user mode.


          • 2. Re: How would filemaker handle this situation
            grinch
              

            What would happen if the instead of a global field in the same table, the value was stored in a field in a related table?  Ultimately I am trying to count the number of times an event happens across all the users of my database (how many times anything is printed).  Originally my database was designed with only a single user in mind.  However, we are now thinking about adding additional users, and I see many things that may cause a problem.

             

            Thanks,

            Chris

             

            • 3. Re: How would filemaker handle this situation
              comment_1
                

              grinch wrote:

              Ultimately I am trying to count the number of times an event happens across all the users of my database (how many times anything is printed). 


              I believe the best way to do this would be to create a record for each occurrence of the event. Incrementing a value in a field carries two disadvantages: (1) there is no trail, and one mistake is all it takes to lose the entire history, and (2) one user modifying the value locks it and prevents other users from logging their actions at the same time.


              • 4. Re: How would filemaker handle this situation
                mrvodka
                   I agree with comment. You may even want to go one step further and capture the user as well as the event. This way you can keep stats on how many times a particular event was executed.
                • 5. Re: How would filemaker handle this situation
                  grinch
                    

                  OK, I think you guys are right.  Now comes the practical part.  What is going to be the best way to implement this.  Create a related table with 2 fields, the key, and a calculation field.  The calculation field would just be get(TotalRecordCount).  

                   

                  When the event occurs, create a record in this table.  I am thinking of using a combination of timestamp and current user as the key, and allow the creation of records via the relationship.   Now I can place the calculation field on the main layout.  Anyone see any problems with this, or a better way.

                   

                  Thanks

                  Chris

                   

                  • 6. Re: How would filemaker handle this situation
                    comment_1
                       I don't think we have enough details. Do you want the record to say only that user X printed at timestamp Y - or do you want to associate this with a specific record in your current table? IOW, what is the purpose here?
                    • 7. Re: How would filemaker handle this situation
                      grinch
                        

                      Ultimately any user needs to be able to see is how many times this particular layout has been printed by all the users of the database.  It does not matter what record the layout contained when it was printed, just that this particular layout has been printed.  This always worked fine with a single user, just by incrementing a global field called "printCount" when the print script was run.

                       

                      Chris

                       

                      • 8. Re: How would filemaker handle this situation
                        comment_1
                          

                        Then a PrintLog table with the following fields should be sufficient, I think:

                         

                        • LogID (Auto-enter serial number)

                        • Timestamp (Auto-enter creation timestamp)

                        • User (Auto-enter creation accouht name)

                        • cTotal, calculation = Get (TotalRecordCount)

                         

                        To show the total  in a layout of another table, define a relationship using any pair of fields and the x relational operator.