2 Replies Latest reply on Jul 8, 2015 1:56 AM by starstuff

    How to batch auto-increment a field?

    starstuff

      Title

      How to batch auto-increment a field?

      Post

      Hi All,

       

      im trying to auto-increment a field by 100, the records are based on notebooks with 100 pages sheet, these are the 100 auto-increment.

       

      i have a tested looping it, but cant get the value right, it doesnt add up.

       

      im using a global start and global end field for the count. 

      example i set in the global start 1 and global end at 100

       

      i will then run the script to create the new records, but i cant get it to work.

       

      The script is

      Set Variable [$start; Value: RECORD::g_start]

      Set Variable [$end; Value: RECORD::g_end]


      Loop

        Set Variable [$count; Value: $start + 1]

         New Record/Request

         Set Field [ RECORD::page_number ; $start - $count]

          Exit Loop If[ $count > $end]

      End Loop

       

      What is wrong with the script? im getting the loop, but it always with the same number

       

      Thank you!

       

       

        • 1. Re: How to batch auto-increment a field?
          philmodjunk

          In your script $count is always the same value, the value of $start + 1

          Looks like this is what you want:

          Set Variable [$start; Value: RECORD::g_start]

          Set Variable [$end; Value: RECORD::g_end]


          Loop

               New Record/Request

             Set Field [ RECORD::page_number ; $start + $count]

             Set Variable [$count; Value: $count + 1]

          Exit Loop If[ $start + $count > $end]

          End Loop

          • 2. Re: How to batch auto-increment a field?
            starstuff

            Hi PhilModJunk!

             

            thanks for the script, its working great! :)

            in your script, i like to ask does the Looping cause the Set Variable [$count; Value: $count + 1] to stores the count number? is that the way it works?

             

            and one more thing, i need to add one more field is to have a record that answers how many notebook are already used,

            new field: RECORD::NotebookCount

            so for every 100 pages = 1 notebook.

             

            i would like the script to add to the current max value of the RECORD::NotebookCount after every 100 pages

             

            the script is something like this

            Set Variable [$start; Value: RECORD::g_start]

            Set Variable [$end; Value: RECORD::g_end]

            Set Variable [ $notebookcount ; Value: Max ( RECORD::NotebookCount)]


            Loop

                 New Record/Request

                 Set Field [ RECORD::page_number ; $start + $count]

                 Set Field [ RECORD::NotebookCount ; $notebookcount]

                 For every 100 $count

                          Set Field [ RECORD::NotebookCount ; $notebookcount + 1]

                 Set Variable [$count; Value: $count + 1]

            Exit Loop If[ $start + $count > $end]

            End Loop

             

            how to do this?

             

            Thank You again!