8 Replies Latest reply on Oct 23, 2008 7:03 AM by TSGal

    Script problem

    Butch

      Title

      Script problem

      Post

      I need help writing a script!

      Script needs to create up to 4 records, print labels for those records and then delete records.

      For example:  Customer orders 4 portions of breakfast.  From customer's order record I need to print 4 identical labels.  I assume the way to do it is to create 3 identical records, print labels for each record and then delete records.  Hopefully, there is an easier way. 

      Thank you for any suggestions!

        • 1. Re: Script problem
          TSGal

          Butch:

           

          Thank you for your post.

           

          For this example, let's assume you have a "Customer" database.  Somewhere, you are entering a number into a "Quantity" field, and that dictates the number of labels to be printed.

           

          1. Create a "Label" Table that includes a field you want printed on each label.  For this example, name it "TEXT".

           

          2. Create a new script and entitle it "Print Labels".  Enter the following commands:

           

          Go to Layout [<layout with Quantity entered>]

          Enter Browse Mode []

          If [Quantity <= 0 or IsEmpty (Quantity0]

             Exit Script

          End If

          Set Variable [$label; Value: Quantity - 1]

          Go to Layout [<layout where printing labels>]

          New Record/Request

          Set Field [TEXT, "This is a test"]

          Loop

             Exit Loop If [$label = 0]

             Duplicate record/Request

             Set Variable [$label; Value: $label - 1]

          End Loop

          Print [Restore; No dialog]

          Delete All Records []

          Go to Layout [<back to layout where Quantity is entered in first step>]

           

           

          What this does is goes to the layout where you enter the Quantity.  We make sure you are in Browse mode and then check to make sure there is a Quantity greater than 0 so we know how many labels to print.  If the value is zero, empty, or a negative number, we immediately halt the script.

           

          Now that we have the number of labels to print, we initialize a variable to the number of labels minus one.  The reason will become evident.

           

          Next, we switch to the layout where you are going to print labels and add a new record.  We then set the TEXT field to "This is a test".  You can change this to whatever you want.  Since we added one record, that is the reason for setting the value above to the number minus one.

           

          Next, we enter the loop to start duplicating records.  First, we check to see if we reached zero, and if so, we exit.  Otherwise, we duplicate the existing record and decrement the number of labels left to be printed.

           

          Once we finish creating our records, we print, delete all the label records and return to the original layout.

           

          This should get you pointed in the right direction.  If you have any questions or need clarification for any of the above steps, please let me know.

           

          TSGal

          FileMaker, Inc. 

           

          • 2. Re: Script problem
            davidhead
              

            Actually, I don't think it needs to be that complicated TSGal. ;)

             

            I think all that is needed is a layout where the label information is duplicated four times.

             

            Let's say you had a layout with two labels across and four labels down. You would be able to print labels for eight records.

             

            Now you go into layout mode and change the layout print options (Layouts > Layout Setup > Printing) to print in one column only. Back in layout mode, you duplicate the data from the first label onto the position of the second "label" on the right. Now back in Browse mode you have two labels for each of four records per page.

             

            Now you repeat the process by making the body part of the layout twice as high. Duplicate the label data down to the "second row". Now back in Browse mode you have four labels for each record - two records to a page.

             

            No duplication and deletion of records required. 

             

            Does this make sense to you Butch? 

            • 3. Re: Script problem
              TSGal

              David:

               

              Good call!

               

              I was reading into the post that the person may order "x" number of breakfasts.  If a group comes in and orders 9 breakfasts, I wanted a way for the number of labels to be dynamic without having to copy and paste.

               

              You could also set up 10 different layouts showing 1, 2, ... 10 labels.  Then, you can select the layout based on the number.

               

              TSGal

              FileMaker, Inc. 

               

               

              • 4. Re: Script problem
                Butch
                  

                 

                Hi David,

                Thank you for the response.  Let me complicate the situation a little.

                What if I have 20 different orders with different portions of breakfast?  Each order record orders between 0 and 6 portions of breakfast.  I need to evaluate each record and determine the number of labels necessary by the number of portions they have ordered.  Including printing no label if they ordered 0 portions.

                Will your method still work for this?

                Thanks again for your help

                Butch

                • 5. Re: Script problem
                  pmconaway
                     Couldn't you do all this by printing multiple copies of the same label and the number of copies is based on the portions ordered. I do realize that you will have to create a special case(script) if the portions are 0.
                  • 6. Re: Script problem
                    TSGal

                    Butch, pmconaway:

                     

                    My original script takes into account 0 orders (no printing), and also anywhere from 1 to 6 orders.

                     

                    You could make the number of copies in the Print dialog to the number of orders, and that will work for one label per page.  However, if you have more than one label per page, then my original script will work.

                     

                    The other option is to have six different layouts.  The first with one label, the second with two labels, etc.  You then select which layout to print from either manually or through a script that selects the layout by number.

                     

                    I like the ideas coming out of this post.  Any more? 

                     

                    TSGal

                    FileMaker, Inc. 

                    • 7. Re: Script problem
                      davidhead
                        

                      I would do this using a related labels table. The script would create labels with a unique key looping through the found set of records and creating as many labels for each parent record as required (based on a field value). Then when all records had been processed, go to print the labels. Then you could delete the label records if the print was OK.

                       

                      I could do a sample file but I don't see any way of posting files on this forum.

                       

                      TSGal or ModMan is there a way to post files? 

                      • 8. Re: Script problem
                        TSGal

                        David:

                         

                        Right now, it is not possible to post a file to the forum.  We (FileMaker, Inc.) looked into hosting files, but there are some legal concerns with "appropriate" material, added to that the storage overhead and the inability to link a file back to a post.  Hopefully, we will be able to accept files in the future.

                         

                        TSGal

                        FileMaker, Inc.