6 Replies Latest reply on Nov 7, 2014 7:25 PM by aklobby

    Get(CurrentDate) finding the day before and current date

    aklobby

      Title

      Get(CurrentDate) finding the day before and current date

      Post

      I am having an odd issue with the following script finding records for the current day as well as the day before. I want to only show records that correspond with the current date. Has anyone else had this issue? Can anyone spot an anomaly in this script that I cannot see? Any help greatly appreciated I have been staring at this script and cannot see what I am doing wrong.

      Allison

      Set Error Capture [On]

      Go to Layout ["Print List Layout"]

      Enter Find Mode

      Set Field [Scheduled; Get(CurrentDate)]

      Perform Find

      If [ Get(FoundCount) =0

      Show custom dialogue ["no records found, Click OK to return to the report creator"]

      Go to Layout ["Reports"]

      Halt Script

      End If

      Sort Records [Restore; No Dialogue]

        • 1. Re: Get(CurrentDate) finding the day before and current date
          schamblee

          You are not clear on your posting.  Your script only search for the current date not the previous date.   If the above script is having problems finding the current date then I would suggest looking at your scheduled field and make sure it is of type date.  To also search for the previous days date then you will need to add to your script after your set field statement  and before your perform find statement you would add a new/record request and then another set field statement with Get(CurrentDate)-1.

          • 2. Re: Get(CurrentDate) finding the day before and current date
            aklobby

            Thank you for your response. I have double checked and the field type is Date. I am only trying to search for the current date, but somehow it is finding both current and the day before. 

            Allison

            • 3. Re: Get(CurrentDate) finding the day before and current date
              philmodjunk

              Not all script details are visible in your retyped script. Can you post an exact copy?

                   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 New 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: Get(CurrentDate) finding the day before and current date
                aklobby

                 

                Here is the actual script, not the retyped version. I am beginning to think my issue is more with my relationships than with this script. But if you happen to spot an error in this script, I would appreciate the heads up. 

                Set Error Capture [On]

                Go to Layout [ “Print List Bills” (mb_MASTERDATA) ]
                Enter Find Mode [ Specified Find Requests: Find Records; Criteria: mb_SHEDmd::Scheduled: “//” ] [ Restore ]
                Perform Find [ ]
                If [ Get(FoundCount) =0
                Show custom dialogue ["no records found, Click OK to return to the report creator"]
                Go to Layout ["Reports"]
                Halt Script
                Sort Records [ Keep records in sorted order; Specified Sort Order: mb_SHEDmd::Scheduled; ascending mb_MASTERDATA::CompleteBillNo_Web; ascending ] [ Restore; No dialog ]

                 

                • 5. Re: Get(CurrentDate) finding the day before and current date
                  philmodjunk

                  That's not even the same script. You sure you posted the correct script?

                  And as I suspected, your relationships and table occurrence context is probably the issue here.

                  The table occurrence specified for your layout is:

                  mb_MASTERDATA

                  That makes this table occurrence your "context". Any records found by your script are records from this occurrence's data source table.

                  But the search criteria that is specified is from a table occurrence named:

                  mb_SHEDmd

                  This means that you are telling FileMaker to find all records from mb_MASTERDATA that have at least one related record from mb_SHEDmd with today's date. Once the find is performed, however, you return to Browse mode and all related records from mb_SHEDmd will be visible for the records from your found set, both those that have today's date and those that do not.

                  It is entirely possible that you should be performing this find on a layout based on mb_SHEDmd.

                  • 6. Re: Get(CurrentDate) finding the day before and current date
                    aklobby

                    PhilModJunk, 

                    Thank you for your insight. I indeed needed the layout to reflect the correct TO. It works now like a charm. Thank you for helping me see the forest for the trees. 

                    Allison