2 Replies Latest reply on Mar 21, 2011 10:06 AM by philmodjunk

    synchronizing serial numbers

    MPhillipps

      Title

      synchronizing serial numbers

      Post

      I have two forms that I want to synchronize the sequential serial number.

      Is there a way that I can generate serial numbers that are sequential and used between two or more tables?

        • 1. Re: synchronizing serial numbers
          GianandreaGattinoni

          if I have understood your problem, you can use the following script:

          If[Get ( ScriptParameter ) = 1]

          Set Next Serial Value[Table1::IdField1; GetNextSerialValue ( Get ( FileName );"Table2::IdField2")]

          Else

          Set Next Serial Value[Table2::IdField2; GetNextSerialValue ( Get ( FileName ); "Table1::IdField1")]

          End If

          Set this script in the Script trigger on layout OnrecordCommit event

          In Layout for Table1 pass the parameter 1

          So , when it is committed the new record in one of the two tables, the script set the next serial equal to the other table (which was already incremented)

          • 2. Re: synchronizing serial numbers
            philmodjunk

            Do the two forms refer to the same table or different tables?

            If they refer to the same table occurrence, they will stay in synch automatically.

            If different table occurrences, a script performed from one layout can perform a find for the record with matching value in the other.

            If you want a new record created in one layout's table to match the ID number of the current record in the other table, things get more complicated. This last situation implies a relationship between the two tables. Is it a one to one relationship, (Exactly one record in table 1 matches by this ID number to exactly one record in the other table), a one to many relationship (many records in  table 2 have match to the same ID number in table 1) or a many to many relationship?