6 Replies Latest reply on Sep 14, 2014 10:04 AM by DEC

    How to stop restoring Find criteria?

    DEC

      Hi Everybody,

       

      I'm running into a strange anomaly. When the user conducts a find from within a found set, on occasion the find is conducted only within the limited range of records within the found set in existence at the time the new Find is executed.

       

      For example, if I perform a find for Project A, and it returns a single record, and from there I hit the button to Find Contracts, and fulfill the Contract Type field with "Finance," instead of bringing me back ALL records that reflect "Finance" in the Contract Type field, it will return to me only those contracts that reflect "Finance" in the Contract Type field and "Project A" in the Project Name field.

       

      The script is below. The script is complicated by the fact that the Find function implements a new window to conduct the Find, but I can't see whether that makes a difference.

       

      The funny part is that sometimes the script seems to work properly, and sometimes it doesn't.

       

      Any thoughts?

       

      Thanks in advance for your help!

       

      -D

       

       

       

      Set Error Capture [ On ]
      Allow User Abort [ Off ]
      Select Window [ Name: "Find"; Current file ]

      If [ Get ( LastError ) 112 ]

      Close Window [ Name: "Find"; Current file ]

      End If

      Set Variable [ $MainWindowName; Value:Get ( WindowName ) ]

      Set Variable [ $MainWindowWidth; Value:Get ( WindowWidth ) ] Set Variable [ $MainWindowHeight; Value:Get ( WindowHeight ) ]

      Set Variable [ $ScreenWidth; Value:Get ( ScreenWidth ) ]

      GotoField[ ]

      [ Select/perform ]
      New Window [ Name: "Find"; Height: $MainWindowHeight; Left: $MainWindowWidth + 70; Style: Document; Close: “Yes”; Minimize:

      “Yes”; Maximize: “Yes”; Zoom Control Area: “Yes”; Resize: “Yes” ]

      Move/Resize Window [ Name: $MainWindowName; Current file; Top: 0; Left: Case ( Get ( WindowDesktopWidth ) > 2000 ; 50 ; 0 ) ]

      Select Window [ Name: "Find"; Current file ]

      Go to Layout [ “FindAgreements_PopUp_New” (Contracts) ]

      Select Window [ Name: "Find"; Current file ]

      Adjust Window

      [ Resize to Fit ]

      Move/Resize Window [ Name: "Find"; Current file; Height: $MainWindowHeight ]

      Show All Records

      Enter Find Mode [ ]

      GotoField[ ]
      [
      Select/perform ]

      Pause/Resume Script [ Indefinitely ]
      Go to Layout [ “FoundContracts_ListView_New” (Contracts) ]

      Perform Find [ ]
      If [ Get ( FoundCount ) = 0 ]

      Show Custom Dialog [ Message: "No records were found using the designated search criteria."; Default Button: “OK”, Commit: “Yes” ]

      Perform Script [ “Close Find Pop Up” ]

      Else

      Close Window [ Name: $MainWindowName; Current file ]

      Select Window [ Name: "Find"; Current file ]

      Move/Resize Window [ Current Window; Height: $MainWindowHeight; Width: $MainWindowWidth; Left: ($ScreenWidth/2) - ($MainWindowWidth/2) ]

      Set Window Title [ Of Window: "Find"; Current file; New Title: $MainWindowName ]

      Go to Layout [ “FoundContracts_ListView_New” (Contracts) ]

      Sort Records [ Keep records in sorted order; Specified Sort Order: Projects::d_ProjectTitle; ascending Contracts::d_Contract_Type; based on value list: “Contract Type” Contracts::d_ContractDescription; ascending
      Contracts::d_OpposingParties; ascending ]

      [ Restore; No dialog ]

      Go to Record/Request/Page

      [ First ]

      End If

       

        • 1. Re: How to stop restoring Find criteria?
          keywords

          A feature of the ability to open multiple windows is to give you multiple views of your data—including different found sets. If you start with window A with a particular found set, then move to window B to perform a new find, then go back to window A, you will be viewing the original found set, not te new one. Without studying your script in detail I suspect that all those window steps are causing something like that issue.

           

          If you have FMAdvanced, use the debugger to step through the script to watch exactly what is happening. If you don't I suggest you make a copy of your script, remove all the window navigation steps so that you script is addressing only the find steps  in order to isolate whether the find steps are achieving what you intend.

          • 2. Re: How to stop restoring Find criteria?
            DEC

            Hi There!

             

            The solution in question is designed to pop open the find window so that if no records are found, then the find window can be closed, returning the user to the found set she originated from.  That's a great feature, but it could be very well causing these issues, though the problem only started arising tonight and didn't arise at all with a prior version of the database.  In my mind, the biggest suspect was this line, which appears right before the "Perform Find" step" 

             

            Go to Layout [ “FoundContracts_ListView_New” (Contracts) ]

             

             

            But I removed it and the issue appeared sometimes; and sometimes it doesn't.  The inconsistency is the maddening part for me, lol... any thoughts would be much appreciated!

            • 3. Re: How to stop restoring Find criteria?
              keywords

              I already gave you some thoughts, but to reiterate:

               

              It seems to me you have many seemingly unnecessary window navigation steps that are probably causing confusion as to what is happening and where. Ditch all the window navigation steps (if you have FMAdvanced you can simply disable these steps, otherwise make a copy of the script and remove them) and make sure the FIND parts of your script are working as intended. Once you get that sorted out, then start adding back the navigation.

               

              A couple of other thoughts:

               

              1.     You have nothing at the head of the script to establish a starting context; this could be part of the reason you get inconsistent outcomes, as this, to some extent, will depend on the context from which the script is initiated.

              2.     It would seem to me possible that, in certain circumstances (i.e you do not get error no 112, whatever that is) that you could end up with two windows named "Find" (see lines 3 and 11); that could cause inconsistency—which one will FM do things with?

              3.     The line you have identified could certainly be problematic; it's not a good idea to switch layouts between, presumably, entering Find criteria (line 20) and performing the Find (line 23).

              • 4. Re: How to stop restoring Find criteria?
                Mike_Mitchell

                What is the user doing while the script is paused?

                • 5. Re: How to stop restoring Find criteria?
                  DavidJondreau

                  I agree, your window management is a little over the top. I get that you're letting the user do a find and if it's not successful, returning them to their previous set. Go to Field before a New Window is weird. changing layouts before the Perform Find, isn't standard. All the resizing, etc followed by an Adjust to fit. It's probably not the cause, but it makes it hard to diagnose.

                   

                  First question...do you have any script triggers on any of these layouts?

                  • 6. Re: How to stop restoring Find criteria?
                    DEC

                    After testing, it seems that your collective advisement (Mike, Keywords and David), the system seems to be working fine.  I implemented the modal window suggestion, I froze the windows before conducting the sort, and I conduct the search twice in order to avoid rentention of the modal characteristic of the Find window.  It runs very fast, and seems to be working fine.  Thanks so much for all of your help!!

                     

                    -D