1 Reply Latest reply on Oct 21, 2013 11:08 AM by philmodjunk

    Create New Records Script

    JohnJones_1

      Title

      Create New Records Script

      Post

           I am pretty new to scripting. I am trying to create a script that asks for an input number of new records and then generates that number of new records. The script below creates 1 new record. I would guess that I am not capturing the input number correctly but I can't figure out what I am doing wrong.

           Thanks, John

           Show Custom Dialog [ Title: "New Records"; Message: "How many new records?"; Buttons: “OK”, “Cancel”; Input #1: Registrations and Intros::NewRecCount ]

           If [ Get (LastMessageChoice) = 2 or IsEmpty (${Registrations and Intros}::NewRecCount) ]

           Exit Script [ ]

           End If

           Set Variable [ $NumSoFar; Value:0 ]

           Loop

           If [ $NumSoFar ≥ ${Registrations and Intros}::NewRecCount ]

           Exit Script [ ]

           End If

           New Record/Request

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

           End Loop

           Exit Script [ ]

        • 1. Re: Create New Records Script
          philmodjunk

               Unless you specify Global Storage for NewRecCount, the New Record/Request step creates a new record and in that record, NewRecCount is empty and thus $NumSoFar, with a value of 1 is greater than this empty field and your script exits after the first new record. If you specify global storage for that field, you script should work, but it can be simplified:

               Show Custom Dialog
               Loop
                 Set Variable [$K ; value: $K + 1]
                 Exit Loop If [$K > ${Registrations and Intros}::NewRecCount ]
                 New Record/Request
               End Loop

               Ps, and I'd rename that field to remove the need for the ${ } enclosing it in each calculation where you use it.

               I'd rename it to Registrations_and_Intros, RegristrationsIntros or something.