9 Replies Latest reply on Mar 18, 2013 10:59 AM by EricaJackson

    Script to auto enter separate timestamp record



      Script to auto enter separate timestamp record



           I need a script that would automatically create a new record for a timestamp each time the main record is entered

           the 3 tables are CLIENT ;     VISIT  ;  TIME.  The VISIT table is the anchor and has a join Table Occurance of TIME joined by  globalVisitDate and the CLIENTID and an Table Occurance of the Client joined by the Client ID

           VISIT  >-- gVisitDate --<  visit_Time  >--- Client_ID ----<  visit_time_Client

                      >--Client_ID --< 

           On any visit, data may be entered many times throughout the day into that one recod and I need to be able to track it. I am still very confused at script writing.

           Any Help is greatly appreciated!

           Thanks, Erica

        • 1. Re: Script to auto enter separate timestamp record

               So you want a script to create a new record and enter th current timestamp?

               Into which table?


               From the Current record in Visit?

          • 2. Re: Script to auto enter separate timestamp record


                 I am confused about what you are attempting to do.  So if a FMP user acdesses an existing record, a new record is created?  And on that new record would be nothing but a time stamp?  And where would that new record be located (what layout)?  Or are you looking for another field on the same record with a new time stamp in it?  Two entirely different processes.  Don't know if I have an answer for you either way but might be fun to noodle around in search of one.


                 Uncle_ Bill

            • 3. Re: Script to auto enter separate timestamp record

                   Phil and Uncle_Bill

                   I have the main layout based on the VISIT table and a portal on it from the visit_Time table occurance and these all relate back to each individual client.  Each Client record will have many Visit records and eac visit record will have many time records.  I would like to be able to track with a timestamp each time the VISIT Record is opened. I'm thinking I need a script trigger, but I'm not sure of how to set it up, how to write the script and where to attach it...   So one Visit record could have as many timestamp records as needed.

                   The Visit table (anchor) >---------------------------------------------<  visit_TIME (join bouy) >-------------------------------------<  visit_time_Client (bouy)

                                                          VISIT::gVisitDate>---<visit_Time::CD_Time                    visit_Time::Client_IDfk >--------visit_time_Client::Client_IDpk

                                                          VISIT::Client_IDfk >---< visit_Time::Client_IDfk  

                   The users are supposed to log their times, for the VISIT record, using the time portal. (there are "start" and "stop" timestamp fields) I do have "start" and "stop" timestamp buttons in the time portal but it is easy for the user to get distracted and forget to click one or the other, they the go back and manually enter the time, the problem is when they manually enter the time spent, they are making errors and there are overlaps in timebetween the records they can't be in 2 places at once and they do have to go back and forth between visit records for each client, they cannot complete one record at a time. I am also trying to weed out the users that misrepresent their time spent. If I can create what I am envisioning I can quicky sort all the time records for that visit date to make sure there are no overlaps.

                   I hope this makes sense.


              • 4. Re: Script to auto enter separate timestamp record


                     When you creat a script (script_manage scripts_new) The is a script step or trigger that "activates" when a user navigates into a record.  There is also a script trigger that "activates" when a user leaves a record.  Your solution could be as easy as activating the script trigger when they enter a record followed by a reminder or custom message to enter their time.  Like wise whenthey leave that record a trigger is activated that reminds them to again enter their time.  

                         Any way I think you are looking for the scipt triggers that activate upon entry and exist of a record.  If I get a chance I will look for the exct location of those two.


                     Best regrards,


                • 5. Re: Script to auto enter separate timestamp record

                       Thanks Bill

                       I'm thinking a script to say "whenever a user creates, adds to or changes a VISIT record, go to the visits_Time portal and add a new record" that would have an autoentered creation date field. I think I know how to set the script trigger in the portal field for the auto creation date but I'm having trouble with the script steps to go from the Visit table to the portal  to open the record in the realted table.

                       Happy St Patrick's Day!


                  • 6. Re: Script to auto enter separate timestamp record


                         You are on the right track.  Seems to me that you may need to break down your script into smaller "bites".  My previous comment about activating the trigger "upon entering a record" is an option in the script trigger menu.  As well as activating "upon exiting a reord".  As far as having a trigger activate upon changing, a change is kind of setting in queue and is not "committed" until the user clicks out of the record.  Then change only gets committed when FMP "saves" the change.  So that script trigger would be the same as "upon exiting" a record.  So guess and test small steps at a time. Set up a script that you can activate with a button.  Set it up to enter a time stamp on the correct table.  Trouble shoot just that step and work from there.


                         Good luck,

                         Uncle Bill

                    • 7. Re: Script to auto enter separate timestamp record

                           Thanks Uncle bill

                           I have this script, that works when added to a button, where do I set it as a trigger or what steps do I need ot add to get the record to add automatically?


                      • 8. Re: Script to auto enter separate timestamp record

                             Hi Erica

                             In Layout Mode, go to Layouts>Layout Setup>Script Triggers, you can then attach a script to run at various occasions when entering, exiting, loading a record etc..

                        • 9. Re: Script to auto enter separate timestamp record

                               Thanks Symbister

                               I did what you suggested but was not applicable to what I needed, I put my thinking cap on and added "go to related record" to the beginning of the script and attached it to a button on the schedule list (which is how the user navigates within the layout.)

                               So far seems to be working and tracks when the record is entered.

                               Thanks to all of you:  Phil, and Uncle Bill and Symbister. I am slowly but surely learning with all of your help!