2 Replies Latest reply on Jan 26, 2009 2:34 PM by TSGal

    multiple records from a value list...

    akfangler

      Title

      multiple records from a value list...

      Post

      Hi,
      I'm trying to create a script that will make a set of new records in a table, and auto-fill one of the fields from a value list. The number of new records would match the number of items on the value list. For me, that list will be pretty much static, but some change would happen. Any ideas?

        • 1. Re: multiple records from a value list...
          akfangler
            
          Hmm, well, maybe I have tried the wrong approach entirely. I thought using value lists would be a feasible way to create a set of new records, but on my own don't see any way to do that. SO, maybe I'll try a different route. What I need to do is create a series of new records at once. One field would be a name field, pulled from a name list table, and one other field would be a reference code, which would be the same for all of the created records. What is the best way to script the process of creating the correct number of records, and copying the data from the name table?

          akfangler wrote:
          Hi,
          I'm trying to create a script that will make a set of new records in a table, and auto-fill one of the fields from a value list. The number of new records would match the number of items on the value list. For me, that list will be pretty much static, but some change would happen. Any ideas?

           


          • 2. Re: multiple records from a value list...
            TSGal

            akfangler:

             

            Thank you for your post.

             

            Here is a script that will add "X" number of records to a table.

             

            Set Variable [ $counter ; <static value or field name> ]

            Loop

               New Record/Request

               Set Variable [ $counter ; $counter - 1 ]

               Exit Loop If [ $counter = 0 ] 

            End Loop

             

            That is, we set a variable ($counter) to either a static value or field name that contains the value.  We then enter the loop and create a new record.  We then decrement the counter by 1 and check if it equals zero.  If it does, we exit the loop.  Otherwise, we go back to the top of the loop and add another record and decrement the counter.

             

            I'm not sure where you are getting the Reference Code nor the Name, so you may also want to store these to variables ($ref and $name as an example), and then once you added all the records, find those records and replace the found set.  Maybe something like the following may get you started:

             

            Set Variable [ $ref ; Reference Code ]

            Set Variable [ $name ; Name ]

             

            Set Variable [ $counter ; <static value or field name> ]

            Loop

               New Record/Request

               Set Variable [ $counter ; $counter - 1 ]

               Exit Loop If [ $counter = 0 ] 

            End Loop

            Enter Find Mode []
            Set Field [ Reference Code ; "=" ]
            Perform Find []
            Replace Field Contents [No dialog; Reference Code; $ref ]
            Replace Field Contents [No dialog; Name; $name ]
             
            ------
             
            Hopefully, this will point you in the right direction.
             
            If you need clarification for any of the above steps, please let me know.
             
            TSGal
            FileMaker, Inc.