7 Replies Latest reply on Apr 1, 2010 6:13 AM by mr.b.

    Avoid duplicate New Record - Operator is click happy!

    mr.b.

      Title

      Avoid duplicate New Record - Operator is click happy!

      Post

      Hi All,

       

      As part of a file i have a create new record script. All good, works well.

       

      Only problem is the db is running on an oldish machine so is a little slow especially if it hasn't been used for  an hour or so and the hd has spun down, a new operator has started double clicking on the create new record button if it hasn't produced an immediate result.

       

      Is there a simple way that i can prevent this, maybe a check to see when the last time the new record button was pressed and if it was in the last three seconds then ignore the input?

       

      Any bright ideas appreciated.

       

      It's running on FMP10 on a eMac running 10.5.8. My experience fairly limited and definitely still learning!

        • 1. Re: Avoid duplicate New Record - Operator is click happy!
          Steve Wright

          You could perhaps use a script instead of New Record directly. 

          You can add a custom menu to control the FM toolbar for this also.

           

          In the script use : 

           

          New Record / Request

          Halt Script

           

          This way, it will still que the script to run x times, but it will halt them all after the record is created in the first instance.

          • 2. Re: Avoid duplicate New Record - Operator is click happy!
            mr.b.

            HI SWS,

             

            Thanx for the prompt reply.

             

            I do already have a script, please see below and yes i did have some help!

             

            Where would you suggest putting the Halt Script? I've tried a few places but it still enables me to just keep clicking on the button and creating a new record each time. I know that's the purpose of the button but just trying to prevent trigger happy errors.

             

            • Commit Records/Requests [ Skip data entry validation; No dialog ]
            • Set Variable [ $patientID; Value:Patients::PatientID_pk ]
            • Freeze Window
            • Go to Layout [ “Bookings” (Bookings_to_patient) ]
            • New Record/Request
            • Set Field [ Bookings_to_patient::PatientID_fk; $patientID ]
            • Commit Records/Requests [ Skip data entry validation; No dialog ]
            • Go to Layout [ “Patients - treatments” (Patients) ]
            • Set Field [ Bookings_to_patient::g_sortparameter; "booking" ]
            • Commit Records/Requests [ Skip data entry validation; No dialog ]
            • Go to Portal Row [ Select; Last ]
            • Go to Field [ Bookings_to_patient::Date ]

             

            Many Thanx for your time

            • 3. Re: Avoid duplicate New Record - Operator is click happy!
              mr.b.

              Please excuse the smilies, Didn't realise it would come out like that!

               

               

              • 4. Re: Avoid duplicate New Record - Operator is click happy!
                Steve Wright

                I have smilies turned off :-) so no worries..

                 

                The halt script step should go at the end of the script....

                 

                However, it wont prevent them being click happy 100% 

                 

                i.e,

                If I click on the button x times (before the first new record is created) it should work fine, since the other occurences of that script will then be cancelled at the end of the first record being created..

                 

                However, If I slowly click on the button x times, a new record could possibly be created for each click..

                 

                Personally, I don't have this issue, since I do not use the filemaker toolbar.  The new record buttons in my solution does not exist on the data entry layout, so the halt script (as above) works just fine.

                 

                If you have filemaker advanced, turn on the script debugger and watch what happens whilst running through your script and when you click the same button multiple times, it should give you an idea of whats going on.

                 

                You can go a few steps further of course, by as you suggest setting a timer so to speak.

                 

                i.e at the start, perform a check something along these lines : 

                 

                if [  $$timer < get(currenttime) ]

                 

                  Set variable [ $$timer ;  get(currenttime) +10 ]   // + 10 seconds 

                 

                Your script steps

                 

                [end if]

                Halt Script

                 

                 

                 

                That way, if I have wrote it correctly lol... the script wont run if its triggered within 10 seconds.

                If the script does run, it resets the timer variable for another 10 seconds.

                • 5. Re: Avoid duplicate New Record - Operator is click happy!
                  mr.b.

                  Hi SWS,

                   

                  I went straight for the timed solution and it works perfectly. Thank you so much. Saved me banging my head for another few hours!

                   

                   

                   

                  Without wanting to push you further but i have one other problem with the same script and then my solution is complete. I hope you don't mind but could you have a quick look at it for me? I did post it earlier today but so far no replies.

                   

                  Here's the post:

                   

                  I have a portal that displays records that are appointments.

                   

                  It is set to sort the records so that the most recent is at the top of the list. So far so good.

                   

                  My only problem is that when you create a new record in the portal, it appears in the last row of the portal, whereas i would rather it would appear at the top of the portal, ahead of the previous booking. If i just click of the fields, it then re orders it but I'd rather it was at the top.

                   

                  The script has a step that is "Goto Portal record Select:Last" and I have tried changing this to "First" but that then just puts the cursor into the most recent appointment rather than a blank new record.

                   

                  Any ideas how i can make this happen?

                   

                  Many Thanx in advance

                  • 6. Re: Avoid duplicate New Record - Operator is click happy!
                    Steve Wright

                    Instead of taking advantage of 'create records via this relationship' which it sound like that is the way you are doing it, you may instead want to do something like add a button to create a new related record, which runs the following script  :

                     

                    Freeze Window 

                    Set Variable [ $parent_id : main_table::id ]

                    Goto Layout [ appointments ]

                    New Record

                    Set Field [ foreign_id ; $parent_id ]

                    Go to layout [ original layout ]

                    Go to object [ portal object name ]  // give the portal a name via the object info box ( or inspector box in 11 )

                    Go to portal row first

                     

                    Assuming, you are sorting by something like a created timestamp, which is automatically entered when creating new appointment records.

                     

                     

                    • 7. Re: Avoid duplicate New Record - Operator is click happy!
                      mr.b.

                      Hi SWS,

                       

                      Sorry for the delayed reply, but work has got in the way as usual. I've only sat down today to try what you suggested and am very happy to say it works. I didn't have a timestamp field in with the booking but I do now and it all works perfectly.

                       

                      Thank you so much for taking the time to help me. It's a pretty steep learning curve here but slowly, very slowly it's sinking in.

                       

                      Many Many Thanx

                       

                      Mark B