5 Replies Latest reply on Feb 27, 2013 4:20 PM by philmodjunk

    Help with creating multiple new records via Script

    julieFrith

      Title

      Help with creating multiple new records via Script

      Post

      Hello

       

      Can anyone help. 

       

      I have a database which based on a number entered i need to create multiple new records to that number as well as create a unique code for each record. 

      I'm struggling how to achieve this so any help would really be appreciate.

       

      Thanks in advance

      Jules

       

       

      Example

      Field Content Data Entered

      Estate Name                           JulesEstate

      Number of Apts                   50

      Estate Reference:               JE

      Estate Reference Code:      (script generated result) 

       

       

      In this example i would need it to generate 50 new records and in each Estate Reference Code enter a combination of the Estate Reference and sequencial number of apartments entered. eg.

      JE001

      JE002

      JE003

      JE004 etc.  (Note: i need this to be 3 numbers as we have apts blocks which are in the hundreds)

       

       

       

       

       

       

        • 1. Re: Help with creating multiple new records via Script
          philmodjunk

          Set Variable [$Estate ; Value:  YourTable::Estate Reference Code]// If this is a global field you don't need the variable here
          Loop
            Set Variable [$i ; $I + 1]
            New Record/Request
            Set Field [YourTable::Estate Reference Code ; $Estate & $I ]
            Exit Loop If [$I >YourTable::Number of Apts ] //I'd make Number of Apts a global field as it doesn't apply to any one record in your table.
          End Loop

          PS. you are likely to need a related table where you have one record for each estate related to this table where you have one record for each apartment.

          • 2. Re: Help with creating multiple new records via Script
            julieFrith

            Hiya

            Thanks for this. While it is a little over my head i have sort of tweaked it so that the new records go onto a new table. 

            Can we also get the script to copy the other data into each new record it creates? such as the Estate Name etc?

            Jules

            • 3. Re: Help with creating multiple new records via Script
              philmodjunk

              You could, but that would be redundant and denormalizes your data. (The same data is now stored in two different fields. Not only does this take up storage space where you don't need to, if you ever have to update that data, you have to update it in multiple records in exactly the same way.)

              I'd just keep the Estate Name in a separate table where you  have one record for each estate and then link it via a relationship via the Estate Reference code.

              Estates::EstateReference::Apartments::EstateReference.

              You can display any data specific to that apartment's estate vial the relationship so that you don't have to enter and maintain multiple copies of the same information for every individual apartment record.

              • 4. Re: Help with creating multiple new records via Script
                BobBlanton

                     Hi there,

                     I am trying to do the same thing with my database- create a certain number of new records by script according to the number I typed in.

                     I have been trying to understand the instructions and tweak it so that it works with mine.

                     I am just wondering for "Set Variable [$i ; $I + 1]"  What does the $i and $1 refer to as I don't really see those fields...

                     Thanks!

                     Heidi

                • 5. Re: Help with creating multiple new records via Script
                  philmodjunk

                       Those are not fields. They are variables.

                       Ps. This thread is over a year old and no longer pops up in Recent Items when a message is posted to it. I am likely to miss any follow on posts that you make. You may want to start a new thread with your questions.