5 Replies Latest reply on Sep 29, 2012 6:14 PM by pgrehan

    Popup value changes after find - newbie

    pgrehan

      I have a popup on a list layout that allows the user to select whether to view "Active" or "Inactive" clients. I use an OnObjectModify script trigger to the script below.

       

      My problem is that after the script performs the find (correctly), the value of the popup menu changes to the a different value. For example, if I select "Active" clients, the find displays only active clients, but the popup display changes to "inactive". The reverse occurs when select "inactive."

       

      I am baffled. What am I missing?

       

      Thanks from a newbie

       

      Patrick

       

      -----

       

       

      Set Error Capture [ On ]

      Set Variable [ $$FILTER; Value:Clients::popup Filter ] If [ $$FILTER = "Active" ]

      Enter Find Mode [ ]
      Perform Find [ Specified Find Requests: Find Records; Criteria: Clients::Active: “Active” ]

      [ Restore ]

      Else If [ $$FILTER = "Inactive" ]

      Enter Find Mode [ ]

      Perform Find [ Specified Find Requests: Find Records; Criteria: Clients::Active: “Inactive” ] [ Restore ]

      End If

       

        • 1. Re: Popup value changes after find - newbie
          LyndsayHowarth

          active is a sub-word in inactive... so you will find both when searching for active.

           

          I like to use the word 'dormant' rather than inactive.

           

          - Lyndsay

          • 2. Re: Popup value changes after find - newbie

            Hi Patrick, that is strange.  What version of FM are you using and what OS version?  Is popupFilter Filter a global?  It should be.  You might try adjusting your script ... The following two examples might be easier.  If on version 11 or 12 you can use:

             

            Set Error Capture [ On ]

            Set Variable [ $FILTER; Value:Clients::popup Filter ]

            Perform Find [ Specified Find Requests: Find Records; Criteria: Clients::Active: $FILTER

            [ Restore ]

            If [ not Get ( FoundCount ) ]

            Show Custom Dialog [ "no records found" ]

            Halt Script

            End If

             

            ... because you can use the variable within a restored Perform Find and directly search for the value of Active or Inactive - and no need for the 'if' test.  Notice I also used script variable ... no need to use global variable (which would require clearing afterwards); script variables die when script ends.  The fact that you do not clear the variable at the end could also be tripping you up.  And it may be a bug.  I haven't seen this reported but if Mac Lion with 11.0v4 or v12, it might be new.

             

            If prior to 11 or if you just prefer seeing the criteria, you can skip setting the variable at all and reference the global directly as:

             

            Enter Find Mode [ ]

            Set Field [ Clients::Active ; Clients::popup Filter ]

            Set Error Capture [ On ]

            Perform Find [ ]

            If [ not Get ( FoundCount ) ]

            Show Custom Dialog [ "no records found" ]

            Halt Script

            End If

             

            OnObjectModify continues to the next field and if there is no other field in tab order, it might pop the global again.  But if it changed the value to Inactive, the trigger would again fire so it doesn't fit.  Another possibility is that you have only allowed for two possibilities (active and Inactive) but what if the field is empty and fires because it had a value prior?  There is no Else to address empty field.

             

            So if you wish, try these scripts and see if the issue remains.  Using the Halt Script should stop the process immediately.  Also if you have Advanced you can walk it through debugger or we would be happy to review the file as well (either here or back channel to one of us).

             

            BTW, if the Halt Scripts work then you'll want to change them to Exit Script [ false ].  I'm suggesting Halt for this test.

            • 3. Re: Popup value changes after find - newbie
              beverly

              Exact-ly (pun). If you find ==Active you will get valid matches. If you use a constant in a relationship, you will get valid matches. So there are ways to use the terms you prefer

               

              Me? I use the field "Active" as a number field and use it like a Boolean. You're either active or not. Matches however you need. If you need a "label", the text can have conditional formatting. Or you can have a checkbox (value = 1 or 0 or ""), and place whatever term you want beside the checkbox.

               

              -- sent from my iPhone4 --

              Beverly Voth

              --

              1 of 1 people found this helpful
              • 4. Re: Popup value changes after find - newbie

                Hey Lyndsay!

                 

                It might be because some fields have both values. Thank you for bringing it up.

                 

                Although using pop-up suggests only one value per field (and that the field only holds Active or Inactive), both values CAN be entered if using shift.  If there is only one value per field then the find wouldn't find both values ... Only if they both existed as multiline (since FM treats multiple values as individual words). :-)

                 

                And that still would not explain why a global enters a different value than selected.  If it isn't a global AND if both values exist in the field then that might explain it. :-)

                • 5. Re: Popup value changes after find - newbie
                  pgrehan

                  Thanks for all the helpful responses!

                   

                  Lyndsay and Beverly -

                  The find was working properly, but I appreciate the suggestions about making the values more clearly distinguishable. I will use the boolean + conditional formatting idea from now on.

                   

                  LaRetta -

                  You solved my problem in the second sentence of your response. I neglected to set the popupFilter field as Global. I keep thinking I am getting the hang of Filemaker only to trip get tripped up on some gap in knowledge.

                   

                  Thanks again.

                   

                  Patrick