2 Replies Latest reply on Sep 10, 2013 1:17 AM by Ronnimmer_1

    How to Create multiple records based on one field entry- only the serial number field changes

    Ronnimmer_1

      Title

      How to Create multiple records based on one field entry- only the serial number field changes

      Post

           Looking to create multiple records based on an entry in one field  - temporary global

           Example:

           Invoice is received with many line items

           Quantities of line items is sometimes more than one - Mostly more than 10, 11,12 13 etc

           We need to generate records for the same description/costs etc.

           Except a serial number is generated is different for tracking - duplicate record works but you

           have to press the button 10 times  and count and delete if you press to many times.

           Fields

           :Serial

           :cost

           :itemdesc

           :itemnumber

           :unit

            

            

            

        • 1. Re: How to Create multiple records based on one field entry- only the serial number field changes
          philmodjunk

               Does that mean that if a lineItem record has a field named Qty with the value 10, you need to create 10 individual records in the LineItem table in place of the single record?

               You'll need a script for that.

               Something like this: (But change names from the example to match your actual database:)

               I am assuming these tables and relationship:

               Invoices-----<LineItems

               Invoices::__pkInvoiceID = LineItems::_fkInvoiceID

               For an explanation of the notation that I am using, see the first post of: Common Forum Relationship and Field Notations Explained

               #Starting from your Invoice or Order layout
               Set Variable [$InvoiceID ; Invoices::__pkInvoiceID ]
               Go to Layout ["LineItems" (LineItems) ]
               Loop
                  #Find all line items for current invoice with Qty greater than 1.
                  Enter Find Mode []
                  Set Field [LineItems::_fkInvoiceID ; $InvoiceID ]
                  Set FIeld [LineItems::Qty ; ">1"]
                  Set Error Capture [on]
                  Perform Find []
                  Exit Loop IF [ Not Get ( FoundCount ) ]
                  Set Variable [$Qty ; LineItems::Qty ]
                  Set Field [ LineItems::Qty ; 1 ]
                  Loop
                       Set Variable [$Qty ; Value: $Qty - 1 ]
                       Exit Loop If [ $Qty = 0 ]
                       Duplicate Record
                   End Loop
               End Loop
               Go To Layout [Original Layout]

          • 2. Re: How to Create multiple records based on one field entry- only the serial number field changes
            Ronnimmer_1

                 It works like a charm... Thanks...