10 Replies Latest reply on Jun 26, 2014 2:14 PM by philmodjunk

    Adding Multiple Items to Line Item

    GokhanKamu_1

      Title

      Adding Multiple Items to Line Item

      Post

           Hello everyone,

            

           I'm trying to add multiple items as a line item with selecting one product only.

            

           First I tried to use packaging system. Created;

           Contacts-----<Line Item>-----inventory>------<packagingitems>-----inventory2... but this is not really working for me.

           Is it possible to write a script that binds items together and says "if this product added to line items add these products there too"?

           If this is possible how should I add this script and where?

           I'm using (at least trying to use) FMStartingPoint 4. Thats why creating kits doesn't work for me.  I can create kits there but I can't add those to invoices and I don't really understand mapping of FMStartingPoint's to attach those items.

           Could anyone please help me on this? Thanks 

        • 1. Re: Adding Multiple Items to Line Item
          philmodjunk

               Creating a "kit" should work for you even with the relationships shown. And you can add the needed self join so that a "kit" item in inventory can link to the individual components that make up that kit With that in place, adding a new line item record can trip a script trigger to perform a script that checks to see if the selected line item is a "kit" item or not. If it is, it can loop through the list of items that make up that kit and add them (and their quantities) to the Line Item table.

               But your relationships seem to be missing a table, Invoices (or Orders).

               Customers---<Invoices-----<Line Items>------Inventory

               You can modify that for kits by adding a new table plus a new occurrence of Inventory:

               Line Items>----Inventory------<Inventory_Kit>-------Inventory|Kit

               Inventory::id_inventory = Inventory_Kit::id_InventoryKit
               Inventory|Kit::id_inventory = Inventory_Kit::id_InventoryComponent

          • 2. Re: Adding Multiple Items to Line Item
            GokhanKamu_1

                 Thank you for quick reply Phil.

                  

                 Ok I did what you said. Reorganised my relationships. It is now;

            Customers---<Invoices-----<Line Items>------products----<packagingitems>----products2

                  

            I even added portal to items to show packaged items and it shows items in the package now.

            I'm stuck at the scripting part.

            Template already have script attached to add line item button on invoice page. How should i change that? Or should I add completely different script to somewhere else?

                 I don't know how to add scripting code but I added picture of script to following link.

                 http://postimg.org/image/9gpi407dt/

                  

            • 3. Re: Adding Multiple Items to Line Item
              philmodjunk

                   You would not change the script to add a line item. You will need to first select a product for that new line item before the script can check that selection to see if it is a kit item.

                   But if you have never created a script before, this is a pretty sophisticated script on which to learn. You may want to hold off on this until you learn more about scripting.

                   Using your latest table occurrence names, but with my field names (so you'll need to use your fields in place of mine), the script might look like this:

                   #This script must be run with the focus still in the row of the line items portal row just added
                   If [ Not IsEmpty ( PackagingItems::id_productKit ) // this is a kit ]
                      Set Variable [$ProductList ; value: List ( PackagingItems::id_productComponent ) ]
                      Set Variable [$QtyList ; value: List ( PackagingItems::Qty ) ]
                      Freeze Window
                      Set Variable [ $InvoiceID ; value: Invoices::id_invoice ]
                      Set Variable [$Qty ; value: Max ( Line Items::Qty ; 1 ) ]
                      Go to Layout [ "Line Items" (Line Items) ]
                      Loop
                         Set Variable [$K ; value: $K + 1 ]
                         Exit Loop If [ $K > ValueCount ( $ProductList ) ]
                         New Record/Request
                         Set Field [ Line Items::id_invoice ; $InvoiceID // link new record to invoice ]
                         Set Field [ Line items::id_Product ; GetValue ( $ProductList ; $K ) // link new record to a product from component list]
                         Set Field [Line Items::Qty ; $Qty * GetValue ( $QtyList ; $K ) // compute a quantity ]
                     End Loop
                     Go to Layout [original layout ]

                   After creating this script, I'd first test this script by adding a button inside the line items portal row to click to run this script. Once that works for you, you can use a script trigger set on the drop down list or pop up menu in your portal row that you use to select a product for that line item.
                        
                    

              • 4. Re: Adding Multiple Items to Line Item
                GokhanKamu_1

                     Well...

                     I told you before how this FMStartingPoint hard to edit it :)

                      

                     I changed a bit.

                     I'll try to explain it.

                     Now starting point has its own structure. 

                     I was able to do something like that

                      

                     T12_Invoices<-----> T12j_Invoices_LINE_ITEM<------->T13_INV_LINE_ITEMS<----->T15_Products<------->PackagingItems<------>T15_Products2

                      

                     T12_Invoices::IDInvoice =T12j_Invoices_LINE_ITEM::id.invoice

                     T12_Invoices::Project_Name=T12j_Invoices_LINE_ITEM::id.project

                      

                     T13_INV_LINE_ITEMS:: Id_invoice = T12j_Invoices_LINE_ITEM::id.invoice

                     T13_INV_LINE_ITEMS:: Id_project = T12j_Invoices_LINE_ITEM::id.project

                     T13_INV_LINE_ITEMS:: Id_product = T12j_Invoices_LINE_ITEM::id.product

                      

                     I used your script like this;

                      

                If [ Not IsEmpty ( PackagingItems::id_productKit ) // this is a kit ]
                   Set Variable [$ProductList ; value: List ( PackagingItems::id_productComponent ) ]
                   Set Variable [$QtyList ; value: List ( PackagingItems::Qty ) ]
                   Freeze Window
                   Set Variable [ $InvoiceID ; value: T12j_invoices_LINE_ITEM::id_invoice
                   Set Variable [$Qty ; value: Max  (T13_INV_LINE_ITEMS::Quantity ; 1)]
                   Go to Layout [ "L171_MAINTENANCE_Invoice_Line_Items"(T13_INV_LINE_ITEMS)]
                   Loop
                      Set Variable [$K ; value: $K + 1 ]
                      Exit Loop If [ $K > ValueCount ( $ProductList ) ]
                      New Record/Request
                      Set Field [T13_INV_LINE_ITEMS::id_invoice ; $InvoiceID // link new record to invoice ]
                      Set Field [ T13_INV_LINE_ITEMS::id_Product ; GetValue ( $ProductList ; $K ) // link new record to a product from component list]
                      Set Field [T13_INV_LINE_ITEMS:Quantity ; $Qty * GetValue ( $QtyList ; $K ) // compute a quantity ]
                  End Loop
                  Go to Layout [original layout ]

                     Here is my problem. With this script I was able to create kit items entries at "L171_MAINTENANCE_Invoice_Line_Items" But they are not appear at Invoice page. I allowed creation through tables too but still nothing happens. I'm pretty much stuck here.

                • 5. Re: Adding Multiple Items to Line Item
                  GokhanKamu_1

                       Well it is working now. I figured that I make mistake at some point.

                        

                       I have one more question.

                       There kit items have their own price, name and stock amount. With this setting their price or name doesn't show at invoice. I can only see their product codes.

                       And I must be able to add this products seperately too

                       What can I do to change these and add stock information on these items?

                        

                  • 6. Re: Adding Multiple Items to Line Item
                    philmodjunk

                         I'm not sure that I am understanding your description.

                         WIth kits, there are two pricing options used by different organizations:

                         Option 1: The kit as a whole has a price so the listed components of that kit must be added, but with no price specified. This is typical of "package deal" pricing where purchasing the items as a group or "kit" costs the purchaser less than if they purchased each item in that group separately.

                         Option 2: The kit item is priced at $0, but each component is priced just as though you purchased the item separately.

                         My best guess is that you want option 1.

                         If so, you can set up your line item prices to be looked up from products as always, but your script that copies over the product ID's and calculates quantities can update the unit price field that normally looks up a price from products to set it to $0.00 to keep the addition of that line item from increasing the total cost of the invoice.

                    • 7. Re: Adding Multiple Items to Line Item
                      GokhanKamu_1

                           I see.

                            

                           What if I don't create packagingitems table and instead of it create kit_id on products page and give that id only to items that we are selling in kit. I can retrieve those items to invoice with modifying a bit your script? There is any reason for this not to work or it needs whole another scripting?

                      • 8. Re: Adding Multiple Items to Line Item
                        philmodjunk

                             That simply seems to be a different method for accomplishing the same result and with a potential for more problems keeping information up to date as won't that method require two records in products for the same item if it can be sold separately as well as in a "kit"? That's not a good idea.

                             And I don't see the need as I believe that I've already described how to make the current set up work for you.

                        • 9. Re: Adding Multiple Items to Line Item
                          GokhanKamu_1

                               I know that you are giving me best advise here :)

                               Actually we don't send our items as a kit. We have around 400 item and when we send one of them we usually send similar 10 item with it. Instead of adding all one by one some I was trying to create some kind of shortcut. Thats why I was trying to avoid kit system.

                               But I got it. Your suggestion is the best way that i can go with.

                                

                               Thank you

                          • 10. Re: Adding Multiple Items to Line Item
                            philmodjunk

                                 We have around 400 item and when we send one of them we usually send similar 10 item with it.

                                 Well to me that IS a "kit" system.... The "similar 10" comprise a "kit" or "package deal" and is handled by what I am describing.

                                 So I don't quite understand what it is about a "kit" that you are trying to avoid....