5 Replies Latest reply on Aug 4, 2016 4:18 AM by coherentkris

    Duplicate entry on OPD


      Hi , there i have facing a problem

      File is installed at Filemaker Server 14, and when client users click on OPD "create a new record" button simultaneously both have been allocated the same number , and when they print the OPD slip i mean after data is entered , suppose one users print the OPD slips he gets the print and when other one prints it , he gets the record of the other user in the OPD slip , cause at making a new record both were allocated the same ID number. Only one record is saved in the ID.

      I am putting the script file here


      Can anyone help me out

        • 1. Re: Duplicate entry on OPD

          Can you break down your question into "when i do this...then A happens and i want B to happen? What you wrote is difficult to comprehend. Clarity is significant in getting effective answers here.

          • 2. Re: Duplicate entry on OPD

            A > User go to layout to create OPD "Means New Record"

            B> When they hit button new OPD above script works and New record is created

            C> Things go fine until two users press the new OPD button at once

            D> When two users press new OPD button at once, both are allocated the same OPD Number.

            E> Both users enters the Data and when they press print OPD

            F> One Users get print out and when other users enters the data and press print out,

            G> He gets the printout of the other user who has already made that record.

            • 3. Re: Duplicate entry on OPD

              Your OPD table needs to have an auto enter auto increment serial number or auto enter calculation of Get (UUID) for the primary key.

              The user never needs to see the PK field so it does not have to be smart like your calculation.


              The two consecutive set fields (one that sets the PK for the record) can cause collision on simultaneous triggering of the script, or near simultaneous, by two distinct users. It takes a brief bit of time to process execute sql select statements that increases the chance of collision. Use auto enter fields validated as not empty and unique for PK values eliminates this chance occurrence.


              You should also look at setting a variable to the contents of current date because calling get ( CurrentDate ) 7 times is wasteful of CPU cycles and causes more delay

              • 4. Re: Duplicate entry on OPD

                i actually found where the problem is

                ExecuteSQL ( "SELECT Max(IDsub) FROM OPD WHERE OPD_Month=? AND OPD_Year= ?";"";"";MonthName ( OPD::CDate );Year ( OPD::CDate ) )+1   <<< this one is causing the duplication can you help me out in adding this 1 as FIFO or time based , cause when both buttons are press at once from both users. number are given to both are same

                • 5. Re: Duplicate entry on OPD

                  Auto increment serial number fields or UUID fields as primary keys solves this issue.

                  If you insist on using your calculation to set the primary key value then you will always have the possibility of data collision for multiple users unless validation is enabled OR if you switch to a more transactional approach to your scripting.

                  Goolge FileMaker Transactions and get familiar with the work done by Todd Geist and the rest of the community.

                  Until then...

                  Set field definition OPD::OPD_idPK to be validated always as unique and not empty.

                  Do not allow user to override.

                  Enable validation on the commit records script step.

                  Program around the situation when validation fails for the duplicate entry.