3 Replies Latest reply on Feb 6, 2015 12:06 PM by philmodjunk

    X amount of Variables for line item copy

    WilliamSouth

      Title

      X amount of Variables for line item copy

      Post

      I looking to make script that copy all line items, my problem is that some line items will be 3 some will be 10

      I am not sure how to make the variable repetitive.

      Here is the script I have made but dose not work right

      Go to Record/Request/Page

      [ First ]

      Loop

      Set Variable [ $lineItemX; Value:Invoices Data::Item ]

      Go to Record/Request/Page

      [ Next; Exit after last ]

      End Loop
      Go to Layout
      [ original layout ]

      Loop

      New Record/Request

      Set Field [ Invoices Data::Item; $lineItemX ]

      End Loop

       

       

        • 1. Re: X amount of Variables for line item copy
          SteveMartino

          Could you explain a little better exactly what you are trying to do?

          Some questions:

          1.  Why do you want to copy all the line items?  Are you trying to create an invoice or report?

          2.  After you copy them, (assuming you need to), then what do you want to do?

          Your present script, if it works at all, will only create one variable, then make endless records setting the same variable.

          • 2. Re: X amount of Variables for line item copy
            WilliamSouth

            We are a tuxedo store and sometimes for wedding parties the groomsmen wear the same thing. So instead of rewriting another invoice I would like to copy all the line items from one invoice to make a new one for the next groomsmen.

            "Your present script, if it works at all, will only create one variable, then make endless records setting the same variable."

            Yes I know this will happen I guess I was one wondering if there is a way for filemaker can almost determine how many Variables I need and then assign them a variable name

            example.

            If  3 line items are present filemaker would make 3 variable $lineItemA; $lineItemB; $lineItemC   (If there more line items it would make more)

            Hope you can understand:)

            • 3. Re: X amount of Variables for line item copy
              philmodjunk

              See this script for duplicating a parent record and its associated child records:

              Duplicating Bill Of Materials (duplicating portal line items)

              Be sure to use the last version of the script found there, not the first one in the thread. No variable for a list of line items are needed.

              If you want to build a list of line items in a single variable, you can use the following set variable step inside your loop:

              Set Variable [$LineItem ; Value: List ( $LineItems ; "New Value Goes Here" ) ]

              You can later use GetValue with a loop counter variable to access one value at a time from the resulting list. There are also ways to set up a repeating variable with a loop counter if you prefer an array to a list.