13 Replies Latest reply on Sep 25, 2013 3:59 AM by MichaelLawrence

    Added Commit Records/Refresh Window script, now new records won't show up.

    MichaelLawrence

      Title

      Added Commit Records/Refresh Window script, now new records won't show up.

      Post


           I'm working with a modified version of the Invoice starter solution.It's going to be used on an Ipad 2 but I'm designing it on my Windows 7 PC.

           I had an issue with some custom buttons I created to plus/minus the quantity count by increments of one, the issue being that the Grand Total field and a custom Field that counts the total quantity of the invoice items wouldn't update automatically (if I clicked or finger tapped near the fields on the Ipad it then would).

           I fixed that by adding 'Commit Records w/no dialog box' and then 'Refresh Window' to the end of the scripts for the buttons.

           I was very pleased, printed out a copy of my invoice. Then when going back to the invoice to further edit it, none of my new additions to the invoice are working. I can still modify the previously existing fields and get the results but otherwise I can't get the new line items to be counted at all.

           Is this related to my use of the commit records & refresh window scripts? Or could this be something else entirely?

            

        • 1. Re: Added Commit Records/Refresh Window script, now new records won't show up.
          philmodjunk

               The modification may have made the problem you are encountering show up more quickly, but commit records/refresh window--neither of which should have been reallynecessary, Would not make records disappear from the portal. If data in a match field has been changed or data in a field means that the related record no longer meets as portal filter's criteria, then the commit/refresh would cause a screen update that shows the record disappearing right away instead of when you click on the layout background or navigate to and from another layout.

               You'll need to examine the data in your match fields and any portal filter expression you might have to determine why the records are dropping out of your portal.

          • 2. Re: Added Commit Records/Refresh Window script, now new records won't show up.
            MichaelLawrence

                 Thanks for responding Phil, your advice is always welcome. My match fields are fairly simple, and I haven't changed any of them as I know of. Basically, I had no issues, and added 20+ records to the portal, everything working great. My calculations fields were working fine until after I printed the records. Is this something I should upload to dropbox?

            • 3. Re: Added Commit Records/Refresh Window script, now new records won't show up.
              philmodjunk

                   I think you need to document exactly what you have set up for your portal and for your scripts that add records. I predict that one of your match fields is not getting the expected value. Commit records, BTW, will cause your layout to "Lose" the focus on a given portal row so if you commit records at the wrong time, this could keep the correct values from being accessible to set field or set variable steps in your script.

                   Posting your script may be all that you need to do.

                   To post a script to the forum:

                     
              1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
              2.      
              3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
              4.      
              5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
              6.      
              7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
              • 4. Re: Added Commit Records/Refresh Window script, now new records won't show up.
                MichaelLawrence

                     Here are my scripts. I have four buttons, two to plus/minus by 1, two to plus/mins by half (the half items are counted by one).

                     They all follow the same basic pattern and script.

                     Insert Calculated Result [Select; Invoice Data::QtyFull Item; If ( Invoice Data::QtyFullItem  ≥  0 ; Invoice Data::QtyFullItem+1 ; Invoice Data::QtyFullItem )] then a commit records/request [No Dialog]

                     The Quantity field (qty) pulls the sum of the two fields for each line item. The calculation is Qty=Invoice Data::QtyFull Item + (Invoice Data::QtyHalf Item*.5).

                • 6. Re: Added Commit Records/Refresh Window script, now new records won't show up.
                  philmodjunk

                       You could actually create just one script in place of all of these by passing the amount to be added/subtracted as a script parameter. Don't really see why you need two quantity fields here.

                       Insert Calculated Result will do nothing at all unless the specified field (Invoice Date::QtyHalfItem or Invoice Data::Fullitem ) is physically present and editable on the current layout. For that reason, I'd use set field in place of this type of "insert" step.

                       But assuming that you still have an unfiltered portal to Invoice Data and that it still matches by the starter solution's original match fields, I see no way that any of these steps can possibly make a record disappear from a portal to Invoice Data.

                       What happens if you remove the commit records step, Click/tab the button to perform the script and then click or tap a blank part of the layout outside of the portal? That also commits the record so it should produce an identical result as your current script.

                  • 7. Re: Added Commit Records/Refresh Window script, now new records won't show up.
                    MichaelLawrence
                    /files/e4772c2bf4/ssInvoiceDetailsIpadLayoutRefreshIssue.jpg 769x529
                    • 8. Re: Added Commit Records/Refresh Window script, now new records won't show up.
                      MichaelLawrence

                           The person who will end up using the database is constantly making physical counts of materials as they come in, and often some items are in less than perfect condition or partially broken, so he's always used the 'half' mark when making counts to make this distinction. Most items are a full Item, and some are 'half'. The reason for the buttons is because he will be using the Ipad while standing over a shipping container as someone physically counts them.

                           The specified fields are physically present on the layout in question, it is based upon the Invoice Data table. It is a slightly modified version of the 'Ipad -> Invoice Details' layout from the Invoice starter solution.

                           I'm sorry if I was vague before, in this layout each line item is added one at a time. You must click the 'Add Line Item' to have another record show up. My issue is not that any items are missing or blank when accessing the record. I had the invoice (seemingly) working fine, by adding over 20+ line items to the invoice and the totals were working fine. I printed out an invoice, and probably 20 minutes later went back to do some more debugging. I started by adding more line items, and they would add to the invoice but they wouldn't be recognized in the Grand Total or Item Total.

                           I took the commit fields off, they didn't make much of a difference. The newer fields didn't take, but then when I closed FMP and re-opened the DB they were calculated into the Invoice. I'm getting a little confused and frustrated to say the least lol

                      • 9. Re: Added Commit Records/Refresh Window script, now new records won't show up.
                        philmodjunk

                             Let's start by looking at each part of your basic set up here. The scripts shown, which I'd still rewrite by using set field instead of an "insert" step, don't create any new records, they just modify a field in the portal row so unless you have something really unusual here, they can't make records appear and disappear out of a portal whether you commit records or not.

                             Please post the add new record script. And have you made any modifications to the basic starter solution relationships and portal setup? Still the same match fields? Is it still an unfiltered portal or have you added a portal filter?

                             And are you using a script to print your invoice? Do you understand that the starter solution script did not print from the layout with the portal but changes to a different layout before printing?

                             To post a script to the forum:

                               
                        1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
                        2.      
                        3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
                        4.      
                        5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
                        6.      
                        7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
                        • 10. Re: Added Commit Records/Refresh Window script, now new records won't show up.
                          MichaelLawrence

                               I have changed some match fields and modified only the unpaid/paid relationships names. Anywhere I could find a 'unpaid' it became 'purchase', and 'paid', it became 'sale'.

                               1) On the customers table I have renamed the paid/unpaid match fields to sale/purchase match field, modified the auto-enter data as well.

                               2) I then changed the name of the relationships for the Unpaid/Paid Match Invoices to Purchase/Sale Invoices.

                               I also noticed that in the Invoice starter solution, the relationship for Unpaid is (Customers::Purchase Match Field = Unpaid Invoices::Payment Status) AND Customers::CUSTOMER ID MATCH FIELD=Unpaid Invoices::CUSTOMER ID MATCH FIELD and for Paid is Customers::CUSTOMER ID MATCH FIELD=Purchase Invoices::CUSTOMER ID MATCH FIELD AND Customers::Purchase Match Field=Purchase Invoices::Payment Status.

                               Does it matter that these are flipped?

                               3) On customers table, the Invoices|All, Unpaid, Paid field names, and the Total Invoices| Unpaid, Paid field names. These definitions seemed to have automatically changed after I renamed the relationships.

                               4) I changed the value-list for payment status to contain purchase and sale.

                               I haven't changed the add new record script or add line item script from the stater solution at all.

                               5) I do realize that the print comes from a separate  'Print/Send Invoices Layout'.

                                

                               My issue is not that the portal has any missing or deleted line items. After working fine for awhile, for some reason after printing the invoice 'grand total field and 'item total field' will refuse to refresh (even with my over zealous commit records/refresh scripts) until I close the DB and reopen.

                          • 11. Re: Added Commit Records/Refresh Window script, now new records won't show up.
                            MichaelLawrence

                                 Well I think I figured out my problem. This is happening on my computer when editing the DB. It is occurring on my modified DB and a brand new Invoice Starter Solution Database that I've made no changes to whatsoever.

                                 I added a visible field of INVOICE MATCH ID to the Layout 'iPad > Invoice Details' in the Invoice Line Item part (the body in layout mode).

                                 It seems as if when I first create the invoice and add all the items I wish, the INVOICE MATCH ID is automatically filled out and done so correctly. But whenever I close out of FMP and then reopen the DB, there is a way to access the layout 'iPad > Invoice Details' that doesn't select the current Invoice ID and use it in the relationship when creating new line items.

                                 After restarting FMP, I am opening the DB, selecting the layout 'Desktop > Invoices', and selecting an Invoice which brings me to the layout 'Desktop > Invoice Details'. Then while in the Desktop> Invoice Details layout, I use the layout selector on the status bar to switch to the layout 'iPad > Invoice Details'. Any new line item created in this invoice will not associate the line item with the current Invoice ID.

                                 And even in the new, completely unedited version of the Invoice Starter solution, any line item after the first one requires me to still click or tap an area near the Grand Total field to get it to update. Any idea why that is?

                                  

                            • 12. Re: Added Commit Records/Refresh Window script, now new records won't show up.
                              philmodjunk

                                   You have two different threads open. I misread your original post to be that new records were dropping out of the portal when you returned to the layout. Now I am confused as to why you have two threads open on the same issue?

                                   But a quick check, shows the answer:

                                   The iPad version of invoice details is directly based on the Invoice Data layout as it does not use a portal. The Invoice Details layout for desktop is based on Invoices. If you use the layout selector to switch to Invoice Details | iPad, nothing takes place to track what record is current in the Invoices table. You aren't in the same table, let alone the same record.

                                   If, on the other hand, you use the layouts as they were designed by tapping the row for that Invoice on the Invoices | iPad layout, a script captures the current Invoice ID value in a global variable named: $$CURRENT_INVOICE_ID. (An invisible button covers the body layout part on that layout and performs the script that loads this variable with a value.) If you check the field definition for the INVOICE ID MATCH FIELD, you'll find that it has an auto-enter calculation that copies the value of this variable into the match field.

                                   Thus, you need to make sure that this global variable gets the correct value before opening the Invoice Details | iPad layout.

                              • 13. Re: Added Commit Records/Refresh Window script, now new records won't show up.
                                MichaelLawrence

                                     I agree I was accessing the layout in a way that was in line with the design of the layout.