1 2 Previous Next 18 Replies Latest reply on Jun 11, 2013 11:53 AM by Svetlana

    Find Script with If/Else if help

    Svetlana

      Title

      Find Script with If/Else if help

      Post

           Hello,

            I am trying to write a find script, and I need to include an If/Else if step (I think?) but am having trouble getting it to work.

            

            I need the script to display all records in the database called Production Master 2 with a value of  "PCA" in the Licensed Status field- where either A) the current date is >= 7 days from the date in the Concept Sub Date field or B) the current date is >= 7 days from the date in the Concept Re Sub Date field.

           I'm not sure how to structure this at all (well, I thought I did and it failed). Any help would be greatly appreciated! I'm still quite new to Filemaker.


           Thank you!

        • 1. Re: Find Script with If/Else if help
          philmodjunk

               Nope. If-else-if is not how you do this.

               You want all records with PCA in the status field that also has the specified range of dates in Concept Sub Date OR in Conceipt Re Sub Date.

               Your scripted find can generate either two find requests. Both requests specify "PCA", but each specifies the date range in a different date field. Or you can perform a find for PCA and the date range inn the first field, return to find mode, specify PCA and the date range in the second field, but use Extend Found Set instead of Perform Find to then include the second set of matching records.

               This thread has a number of scripted find examples--including several that work with date expressions: Scripted Find Examples

          • 2. Re: Find Script with If/Else if help
            Svetlana

                 I would need the script to first search for records with "PCA" and the date range I specified in Concept Sub Date. If no records are found under those conditions, it should then search for records with PCA and the range I specified  in Concept Re Sub Date. Would I still follow the directions in your previous post?  I may be able to achieve the results I want with the second suggestion you made (to use the Extend Found Set step). I will try it out. Thank you for your help and infinite patience.

            • 3. Re: Find Script with If/Else if help
              philmodjunk

                   Does that mean you only search on the Concept Re Sub Date if no matching records are found when you specify a date range in Concept Sub Date?

                   What I original described follows this outline:

                   Enter FInd mode[]
                   Use set field to put "PCA" in the LIcensed status field
                   Use Set field to put your date expression in the Concept Sub Date field
                   New Record/Request ---> in find mode this produces a new request not a new record.
                   Use set field to put "PCA" in the LIcensed status field
                   Use Set field to put your date expression in the Concept Re Sub Date field
                   Set Error Capture [on]
                   Perform Find []

              • 4. Re: Find Script with If/Else if help
                Svetlana

                     Yes, that is what I meant. What would be different in the script under those conditions?

                • 5. Re: Find Script with If/Else if help
                  philmodjunk

                       You might find that you can use the script as written, it depends on how the data is entered into your database. Or you might write the script this way:

                       Enter FInd mode[]
                       Use set field to put "PCA" in the LIcensed status field
                       Use Set field to put your date expression in the Concept Sub Date field
                       Set Error Capture [on]
                       Perform FInd[]
                       If [ Not Get ( FoundCount ) ]
                         Enter Find Mode[]
                         Use set field to put "PCA" in the LIcensed status field
                         Use Set field to put your date expression in the Concept Re Sub Date field
                         Set Error Capture [on]
                         Perform Find []
                       End If

                  • 6. Re: Find Script with If/Else if help
                    Svetlana

                         I thought everything was fine, but now I'm experiencing some issues with the script.

                          

                         Here is what I have:

                         Enter Find Mode [ ]
                         Set Field [ Approval_Master::Licensed Status; "PCA" ]
                         Set Field [ Approval_Master::Concept Sub Date; " = " & Get ( CurrentDate ) & "..." & Get ( CurrentDate ) - 7 ]
                         Set Error Capture [ On ]
                         Perform Find [ ]
                         If [ not Get ( FoundCount ) ]
                          Enter Find Mode [ ]
                          Set Field [ Approval_Master::Licensed Status; "PCA" ]
                          Set Field [ Approval_Master::Concept Re Sub Date; " = " & Get ( CurrentDate ) &  "..." & Get ( CurrentDate ) - 7 ]
                          Set Error Capture [ On ]
                          Perform Find [ ]
                         End If


                         It returns records that fit the date range; however, it now also returns records that fit the date range of the previous time I tested the script. What did I do wrong here? :(

                    • 7. Re: Find Script with If/Else if help
                      philmodjunk

                           Are you on a layout based on Approval_Master or some related table?

                      • 8. Re: Find Script with If/Else if help
                        Svetlana

                             The layout is based on Approval_Master.

                        • 9. Re: Find Script with If/Else if help
                          philmodjunk

                               while

                               " = " & Get ( CurrentDate ) &  "..." & Get ( CurrentDate ) - 7

                               can be simplified to:

                               Get ( CurrentDate ) &  "..." & Get ( CurrentDate ) - 7

                               I see no reason why that would be the case.

                          • 10. Re: Find Script with If/Else if help
                            Svetlana

                                 Out of curiosity, I used your simplified expression instead of mine and now NO records are returned...

                            • 11. Re: Find Script with If/Else if help
                              philmodjunk

                                   Are you sure that these two fields are fields of type Date when you check them in Manage | Database | Fields?

                              • 12. Re: Find Script with If/Else if help
                                Svetlana

                                     Yes, the types of the two fields are Date.

                                • 13. Re: Find Script with If/Else if help
                                  philmodjunk

                                       Sorry, but then I do not see how the results that you are reporting are possible.

                                  • 14. Re: Find Script with If/Else if help
                                    Svetlana

                                         Ah!!! Of course. As I had begun to suspect, the issue was a silly mistake that I made setting up the field. Thank you for pointing me in the right direction :) It is fixed.

                                          


                                         I do have one more (FINAL, I promise) question/plea for help regarding this script.

                                         Currently, the records that are returned by the find script are meeting the criteria specified. How should I go about modifying the script to not display records that have a Concept Sub Date that fits the specified date range if the Concept Re Sub Date does NOT fall within the specified date range (meaning the date in the Concept Re Sub field is less than 7 days in the past from the current date). Unfortunately, that was something I did not take into consideration when I first posted my question. 

                                          

                                         Thank you for your infinite patience and help.

                                    1 2 Previous Next