9 Replies Latest reply on Jun 7, 2010 3:45 PM by dizm

    Scripting Help

    dizm

      Title

      Scripting Help

      Post

      I am a new user to FMP 11 running it on Mac OS X.

       

      I currently have a database set up to place and track orders for a small company. I have an order summary field table/layout with a portal that displays order numbers, total qauntity, and total cost of orders placed by a given customer. Ive been trying to add a scripted button for cases where the items in the order are backorderd. Ideally I'd want it to create a copy of the record on a different table or layout named Back_Orders but i can't seem to make it work. The relationships between order summary are _kf_order_number ( Order Summary)>-----_kp_order_number( Order Form) and the order summary is connected to contacts via a relationship between _kp_Customer_Number( auto entered serial from Customers)-------<_kf_Customer_Number( Order Summary). The foreign key for order summary and customer nuber is populated by a pop up menu.

       

      Any help would be much appreciated.

        • 1. Re: Scripting Help
          philmodjunk

          Sounds like you have:

           

          Order Form::_kp_ordernumber = Order Summary::_kf_order_number

          Contacts::_kp_Customer_Number = Order Summary::_kf_Customer_Number

           

          I'd use a script like this from either an Order Form layout button or a button in a row in a portal to Order Form:

           

          Set Variable[$OrderNumb ; Value : Order Form::_kp_ordernumber ]

          Go To Layout [ "Back_Orders" (Back_Orders ) ]

          New Record/Request

          Set Field [ Back_Orders::_kp_ordernumber ; $OrderNumb ]

          Go To layout [Original Layout]

           

          Note, I would not copy any other data from the Order Form record for this, If I need to see that data on a list of Back_Order records, I can simply use a relationship to display the actual fields.

          • 2. Re: Scripting Help
            dizm

            In your example is Back Order a new table or did you make a new layout based off order form.

            • 3. Re: Scripting Help
              philmodjunk

              In the script step:

               

              Go To Layout [ "Back_Orders" (Back_Orders ) ]

               

              "Back_Orders" is the name of a layout and (Back_Orders) is the name of its table.

               

              So to answer the question, my example creates a record in a new table. This approach would allow you to build a list of back order records that each link by order number back to their corresponding order form records.

              • 4. Re: Scripting Help
                dizm

                Thats exactly what i wanted thanks for the help!

                • 5. Re: Scripting Help
                  dizm

                  The script that you provided works perfectly for the first instance of reporting an order as back ordered however any orders i try to make back ordered after the first dont fill in any values on the back order layout.

                  • 6. Re: Scripting Help
                    philmodjunk

                    The script doesn't fill in any values. It just records the order number. If you then link the back order table to your order form table by this value, you can place fields from Order Form on you back order layout. When the script creates a new record and places the order number in the field, these fields should then show the info from the related record in the Order Form table.

                     

                    Is this what you did?

                    Have you checked to make sure your script is assigning the correct order number?

                    • 7. Re: Scripting Help
                      dizm

                      The order form layout itself has a portal related to a products and a line items table and thats how the orders are place, so im having trouble trying to get all the items in an order to show up on the back order layout, i tried doing a portal but only the first item in the order shows up instead of all the items in the order

                      • 8. Re: Scripting Help
                        philmodjunk

                        Do it this way:

                         

                        You already had this relationship:

                         

                        OrderForm-----<LineItems

                         

                        I've suggested adding:

                         

                        OrderForm-----BackOrders

                         

                        Now add.

                        BackOrders----<BoLineItems

                         

                        Where BoLineItems is a second table occurrence of LineItems and all these table occurrences are linked by order number.

                        Now you can place the related OrderForm Fields on the Back Order layout and a portal to BoLineItems can be placed on it to list the line items.

                        • 9. Re: Scripting Help
                          dizm

                          I found my problem, the portal wasnt based off of lineitems so it was only pulling up the one record