8 Replies Latest reply on Feb 20, 2012 12:51 PM by philmodjunk

    FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script

    fabiuz

      Title

      FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script

      Post

      Hi,

       

      I have lost all the day in this problem and I was not able to found a solution :-(

      In a List layout, I make a quick find to limit the number of found records, than I switch to find mode and in one field I type the text "Yes".

      Such field could be Yes or No, nothing else.

      Then I move to the FM menù and I select "Constrain Found Set".

      It works, I got only the records that have such field set to Yes.

       

      Ok, what I need now is to have the same result using a script.

      The quick find step works like before, than I have set the layout event "OnRecordLoad" that will run this script:

      Enter Find Mode[]

      Set Field [test; "Yes"]

      Constrain Found Set[]

       

      Unfortunately it does not work :-/

      When the script reaches the "Constrain" istruction, the mouse cursor icon become like the Apple Command Key with a dot near.

      It seems some kind of loop. I have to kill FM to exit. 

       

      What could be wrong? I have no more ideas about how to solve or about how to understand what is going wrong :-(

        • 1. Re: FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script
          philmodjunk

          Do you by any chance have a script trigger for the layout such as OnModeEnter? It could be that this script trips such a trigger and the trigger peforms the script Tripping it again in what is now an infinite loop.

          • 2. Re: FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script
            fabiuz
            Thank you for the replay, I have set one event only and it is OnRecordLoad. It seems to be the only event that allows me to sort records after i made a quick search. May be this event is the reason for my problem. I Will try with a different one.
            • 3. Re: FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script
              philmodjunk

              Yes, onRecordLoad would be tripped by the above script.

              What does the script associated with this trigger do? Try temporarily disabling the trigger to see what happens then when you run your script.

              I frequently use this method when I need to temporarily disable such triggers so my script does not trip them:

              In the script like you have posted:

              Set Variable [$$TriggersOff ; value: True ]

              #put the script here

              Set Variable [$$TriggersOff ; value: False ]

              Then in the scripts that I want to disable with this global variable, I enclose the script in an If block like this:

              If [ Not $$TriggersOff ]

                 #Put script steps here

              End IF

              • 4. Re: FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script
                fabiuz

                Many thanks, so the problem is the kind of event I am using to constrain the found set.

                I am using this event because I also need to sort result records when I make a quick find search. 

                This seems to be the only layout event able to catch a quick find action.

                Is there any other way I can use to constrinct and order records when I made a quick find search ?

                 

                Thanks!

                • 5. Re: FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script
                  philmodjunk

                  The method I posted previously allows you to use layout script triggers but enables you to keep scripts from triggering them when this is not desired. This should enable you to use the trigger that you need to respond to Quick Finds.

                  • 6. Re: FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script
                    philmodjunk

                    If [Not $$TriggersOff ]
                       Set Variable [$$TriggersOff ; True ]
                       Enter Find Mode[]
                       Set Field [test; "Yes"]
                       Set Error Capture [on]
                       Constrain Found Set[]
                       Set variable [$$TriggersOff ; False ]
                    End IF

                    • 7. Re: FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script
                      fabiuz

                      I am sorry but I do not understad how to apply your solution.

                      I have made a copy of your script on my layout: it will run when the event OnRecordLoad happens eg. quick find.

                      FMP is still looping.

                      I suppose that $$ vars are global vars, you are enclose the code inside an If, then you set it the global var to True, then my scripts steps are applied then you set the global var to False. The if ends.

                      In this way anything could be stopped. 

                      If I use a script like this:

                       

                      Set Variable [$$TriggersOff ; value: True ]

                      If [ Not $$TriggersOff ]

                         my scipt

                      End If

                      Set Variable [$$TriggersOff ; value: False ]

                       

                      nothing changes: it does not lock FMP but it does never execute my script.

                      So I am still confused about this Embarassed

                      • 8. Re: FM Pro Adv. 11.0v4 Crash when I use "Constrain found set" in a script
                        philmodjunk

                        Which is why I did not suggest you write such a script.

                        Enter layout mode.

                        Select layout setup...

                        Click the script triggers tab.

                        What triggers are selected on this tab?

                        What scripts do they run?

                        A few more thoughts:

                        You can use a script to hide and lock the status area--making the quick find box inaccessible. You can then place a global text field on your layout and use a script to perform the quick find using the data entered into this field. Then you can incorporate the constrain found set steps as the final part of this same script. This should avoid the need for an OnRecordLoad script trigger to constrain the found set.

                        If you want to also constrain the found set when a conventional find is performed, use the OnModeExit trigger to perform the constrain found set script when the user exits Find Mode.