1 2 Previous Next 18 Replies Latest reply on Oct 25, 2012 7:34 AM by moogie

    help simple script



      help simple script


           when field "a" =s and field "b" = ""  in layout "main"         then   print layout "invoice"    and insert s in "main" layout field "b"

           dont know how to say this but both layouts together

        • 1. Re: help simple script

               The fields "a" and "b" should update on both Layouts when you change the contents of the fields.

               Read help on SetField script step.


          • 2. Re: help simple script

                 Do "main" and "invoice" layouts refer to the same table or different tables in layout setup | Show Records From?

                 If different tables, what relationship links them? (How does the script know which invoice to print?)

            • 3. Re: help simple script

                   same table  -   tried following two scripts and various versions  -  dont understand how filemaker thinks  

                   perform find     

                   go to record.... first


                   if (main "a" = s and main "b" = "")

                   go to layout invoice (main)


                   insert text main "b" ; "s"

                   end if

                   go to layout (main) main))

                   go to record (next)

                   exit loop if (main "b" = "s"

                   end loop

                   show records


                   also tried without  print function   -  just trying to  enter s in b     it finds both records but only puts s in one record

                   go to layout (main (main))

                   enter find mode

                   perform find         showed a = s and b ="" in specify find requests

                   perform script (.....)

                   insert text b = s

                   show all records

                   enter browse mode



              • 4. Re: help simple script

                     If they are based on the same table, do you want to print the invoice for the current record?

                     if so:

                     Go to layout [Invoices]
                     Set field [Yourtable::b ; "s"]

                     But I suggest you provide a more complete picture of what you are trying to do and the significance of field "b" in this task you want to script. It's not clear from your attempted scripts whether or not you want to pring just one invoice or a group of invoice and if just one invoice, whether or not that will be the current invoice record.

                • 5. Re: help simple script

                       would like script to search for all records with b = ""   in main               change b to s and print layout inv     for each found record

                       field "b" is just used to show if invoice needs to be billed     (when empty print inv     when not empty do nothing) 

                       i changed program so forget about "a"



                  • 6. Re: help simple script

                         Since both layouts are associated with the same table, you can do a Find Request using the "inv" layout to simplify your script and thinking.


                         The field named "b" is on the "inv" layout.  One nice thing in FMP is you don't have to print objects, fields, lables etc on a Layout.  Thus simplifing a Find request or elimating button etc.


                    To keep objects from printing:
                         1.In Layout mode, select the object or objects that you don't want to print.
                             For more information, see Selecting objects.
                         2.Click Inspector  in the layout bar, then click Position.
                         3.In the Sliding & Visibility area, for Object visibility, select Hide when printing.
                         The general flow thinking on a script would be
                         1) Go to layout inv
                         2) Show all records
                         3) Enter Find mode
                         4) Insert the "s" value
                         5) Find and then Omit to get the non "s" values
                         6)Check to see if you found any records to print, if none, exit script
                         7) Print Inv with option of print all records in found set as print option
                         8) Done
                         PS: I find it easier to right down the flow of script in steps, then it is the coding of the script that is erroneous not my thinking.
                    • 7. Re: help simple script

                           ooops i forgot to clear the "b" field in my script thinking.  [see my point on thinking vs encoding?]

                           Adding new flow step as...

                           7a) Replace all values in "b" field with a value of "s" , since the found set of "" has just finished printing. For printing safety such as jambed printer etc i would also add a field to the database called "Printing Date" and do a replace on found set with Current date.  That way you can recover and reprint if necessary.


                      • 8. Re: help simple script

                             1) i made a table that contains all fields needed to run business
                             2) useing fields, made one main layout that shows all fields needed to  see/enter payables, receivables and daily business functions 
                             3) different layouts were then designed for forms i needed to print/fax/email

                             your general flow
                             6) what function shows none?

                             after printing invoice can i save layout as pdf on main layout?   
                             if invoice printed again need to see what charges were changed   -   where would i store?  

                        • 9. Re: help simple script

                                    if invoice printed again need to see what charges were changed   -   where would i store?

                               Each invoice should represent only one sales transaction. Once the sale has been finalized, settings set up by you in Manage | Security should prohibit users from modifying the invoice.

                          • 10. Re: help simple script

                                 my main customer would prefer one invoice instead of various invoices crediting/debiting   -  is there a function that shows none for your line item 6?  -  can the invoice be stored as pdf? what type field?   -   your remarks have been very helpful tks 

                            • 11. Re: help simple script

                                   Surely you don't send them the same invoice with the same invoice number each time? That can lead to legal difficuties should there be a dispute over the invoice. You need to send them a unique document each time and you should have a unique record each time in your database. That doesn't mean that you can't duplicate an existing invoice record and its accompanying lineitems so that the items listed on the invoice and the total amount could remain unchanged.

                                   The resulting invoice would be identical to the original except for two key details: 1) it would have a different identifying serial number and 2) it would have a different transaction date.

                                   In addition to better record keeping, this results in being able to compute summary totals such as total invoices over a month, quarter, year or other time period.

                                   And yes, you can use Save As PDF to generate a PDF of your invoice and then you can insert it into a container field, but I strongly recommend against using that approach for your invoicing.

                              • 12. Re: help simple script

                                     First issue.... I was talking about a script to print an invoice and the "thinking about the logic flow"

                                     My flow example...


                                          6)Check to see if you found any records to print, if none, exit script

                                     There is not a FMP script function to do that.


                                     You can use the Get (LastError) function to detect the results of the Find Request.  For example....

                                Perform Find []

                                If( Get( LastError ) = 401  )     // Error 401 is "No records match the last [Find] request"   or no invoices were found to print

                                    Show Custom Dialog [" No invoices were found to print."]    // show user a dialog that indicate nothing to print

                                    Exit Script []

                                End If

                                Print    // continue on with the rest of your script to mark "b" and leave


                                Returns a number representing the error, if any, in the execution of the most recently executed script step.
                                     The above example is the classic way to detect after a Perform Find and do my item 6) .  You can check FMP Help for a BIG list of error codes.

                                     Second Issue....

                                     I think I created when i suggested a "printing problem like a paper jamb" in my 7a) step.

                                     What Phil or I don't know is what is included in your INVOICE print out.


                                     your invoice is printed periodically ( weekly, monthly etc) you may show "new charged" line items.  Then you must somehow mark each "line item" as included in Invoice printed[ I suggested Print date or maybe an Invoice number].  Which is an invoice on an Customer Account like a Credit Card company does.


                                     To reprint the invoice, write a Reprint Script to find all for that print date only or that Invoice number only and reprint it.  No need to save the Invoice as a PDF.  The records are still in your database and marked to allow a Find request to pick them out.



                                     your invoice is printed each time there is a transaction.  Then you must somehow mark each as being paid.  Then a new print would include unpaid and new items.


                                     To reprint the invoice, simply run the print script again.


                                     I hope this helps clear some confusion I may have caused.


                                • 13. Re: help simple script

                                       your flow sounds so simple  -  i tried the following

                                       go to layout invoice
                                       show all records
                                       enter find mode       specify   tried both b=s and not entering anything
                                       perform find          specify   omit records b = s

                                       have invoice date, invoice number and times invoice printed fields -  use the insert ( text -  date  and calcuation)

                                       when i run script without loop it puts the information in first record even if b = s

                                       if i use loop it puts several numbers in times invoice printed field (even though its limited to 1) and
                                       shows sometime of figure with "ESC" on it   -   when i press esc button it shows preview of first invoice

                                       seems im doing something wrong with find or????

                                  • 14. Re: help simple script

                                         dont know how i did it but useing the records and find drop down i erased the two records i was useing

                                    1 2 Previous Next