1 Reply Latest reply on Nov 20, 2015 11:47 AM by mikebeargie

    How to automatically add line items in invoice?

    koogorah

      Greetings,

       

      Your expert advice and solution would be greatly appreciated.

       

      Based on the Invoice Starter Solution, is it possible to have a script that will automatically add all products from a specific category into an invoice?Of course not everything in one line item but each product in its own line item? The trigger will be set by checking a check box.

      The process should also not duplicate the item if it already exists.

       

      Many thanks for your support.

      Kunal

        • 1. Re: How to automatically add line items in invoice?
          mikebeargie
          Based on the Invoice Starter Solution, is it possible to have a script that will automatically add all products from a specific category into an invoice?

          Yes. Just loop through your category of product records and create invoice lines from those. Like this:

          Set Variable [ $id ; Invoices::PrimaryKey ]

          Go To Layout [ Products ]

          Perform Find [ the products you want ]

          Go To Record/Request/Page [first]

          Loop

             Set Variable [ $pid ; Products::PrimaryKey ]

             Go To Layout [ InvoiceLines ]

             New Record

             Set Field [ InvoiceLines::InvoiceID ; $id ]

             Set Field [ InvoiceLines::ProductID ; $pid ]

             Go To Layout { Products ]

             Go To Record/Request/Page [ Next ; Exit After Last ]

          End Loop

          Go To Layout [ Invoices ]

          Just a simple loop that creates a corresponding record for each found product in invoice lines, and ties it to your invoice.

          The trigger will be set by checking a check box.

          What happens when your user UNCHECKS that box?

           

          The process should also not duplicate the item if it already exists.

          Then before the "new record" step, perform a find in invoice lines for that matching $id/$pid, and don't create the new record if it exists.