4 Replies Latest reply on Dec 20, 2016 8:41 AM by JulioSandoval

    Incrementing Serial Number

    JulioSandoval

      So I forgot to turn on the feature to Serialize Records.

       

      So I need to do it manually on the existing records and then have the auto-serial continue where I leave off.

       

      But my loop script is not working for some reason.

       

      I am starting with ID IL00006

       

      My Script is as followed:

      Go to First Record

      Loop

      If (not IsEmpty(table::tableID) )

      Go To Next Record ; Exit After Last

           Else

                If (IsEmpty(table::tableID)

                     Set Field (table::tableid ; table::tableID + 1

                         Go to next record ; exit after last

                end if

           end if

      end loop

       

      I have also tried it with setting the ID as a variable

      Set Variable ($ID ; table::tableid + 1)

       

      And I have also tried setting it like this as well:

      "IL00006" + 1

       

      The interesting thing is that the returned value is an 7.

      Does not even return the IL000007 that I would expect.

       

      Thanks guys. Pretty dumb mistake I know. And out of all the other tables, it was the only one that I missed.

       

      Thank you all.

        • 1. Re: Incrementing Serial Number
          TomHays

          The function SerialIncrement("IL0006"; 1) will give you "IL0007".

          • 2. Re: Incrementing Serial Number
            erolst

            JulioSandoval wrote:

             

            So I forgot to turn on the feature to Serialize Records.

             

            So I need to do it manually on the existing records and then have the auto-serial continue where I leave off.

             

            But my loop script is not working for some reason.

             

            I am starting with ID IL00006

            As to the structure of the script, I would write it (generically) like so:

             

            Go to Record [ first ]

            Loop

              If [ not IsEmpty ( ... )

                Set Field [ ... ]

                # if you always write some value, save the If[ ] block and perform the conditional in the result calculation

              End If

              Go to Record [ next ; exit after last ]

            End Loop

             

            If you want to increment a string, use

            SerialIncrement ( "someStringWithTrailingDigits" ; incrementor )

             

            Instead of a script to re-serialize your IDs, try using Replace Field Contents with a calculation like

             

            SerialIncrement ( "IL00006" ; Get ( RecordNumber ) )

             

            JulioSandoval wrote:

             

            And I have also tried setting it like this as well:

            "IL00006" + 1

             

            The interesting thing is that the returned value is an 7.

            Does not even return the IL000007 that I would expect.

            Odds things happen when you add numbers to strings ...

            • 3. Re: Incrementing Serial Number
              keywords

              I'd have thought the simplest way would be to use Replace Field Contents which has an inbuilt update option:

              Screen Shot 2016-12-20 at 1.04.19 PM.png

              1 of 1 people found this helpful
              • 4. Re: Incrementing Serial Number
                JulioSandoval

                Thank you all for your help. Appreciate it!!