3 Replies Latest reply on Dec 6, 2016 10:26 AM by moodog

    Create New Records For Quantity

    moodog

      Looking for a little help on the best way I can do this. I have a main layout table for Raffle Participants. Name, Address etc... Number of tickets is a drop down field (TicketQTY). 1, 2, 3, 4, 5, etc....

       

      A new Participant is entered, the number of tickets is picked from a drop down box.

       

      I have a create ticket button on the form. I would like the script to create the tickets.

       

      I already have a ticket table with TicketID and a Relationship to ParticipantID. So the script would need to create (TicketQTY) X new records in the ticket table and populate ParticipantID. So if we select "5" then 5 new records are created in the ticket table.

       

      I can easily do this for 1, but getting it to count the number of new records is where Im a little lost. Do I loop or can I actually say create 5 records?

       

      Any help greatly appreciated...

       

      Rich

        • 1. Re: Create New Records For Quantity
          erolst

          moodog wrote:

          Do I loop or can I actually say create 5 records?

          You do the former with the latter latter with the former Like ...

           

          If [ IsEmpty [ TicketQTY ) ]

            Exit Script

          End if

          Set Variable [ $participantID ; Participant::ParticipantID ]

          Set Variable [ $ticketCount ; Participant::TicketQTY ]

          Go to Layout [ Ticket ( Ticket ) ]

          Loop

            Exit Loop if [ Let ( $i = $i + 1 ; $i > $ticketCount ) ]

            New Record/Request

            Set Field [ Ticket::ParticipantID ; $participantID ]

          End Loop

          Go to Layout [ original ]

          Set Field [ Participant::TicketQTY ; "" ]

           

          The crucial thing here is to tell when the quantity in your QTY field has already been created, ie to not run that script again. I tried to control that by resetting the field.

          1 of 1 people found this helpful
          • 2. Re: Create New Records For Quantity
            moodog

            Thanks... I got ya.. I think haha.

             

            Ill try that now..

            • 3. Re: Create New Records For Quantity
              moodog

              Awesome.. works perfect.

               

              I made a new field to use for the qty calculation so that I could keep the original number in the record.

               

              thanks again...