9 Replies Latest reply on Jan 30, 2017 11:45 AM by philmodjunk

    Custom Buttons

    cisaac

      I'm trying to overwrite the perform find button to actually constrain find based off a field = 1, does anyone know how I can replace the perform find button to a custom button.

       

      More detail:

      I have a layout that people in the company work from, they can change statuses, notes, and follow-up dates. I also have a patient table where all the accounts get loaded to and as a worker chooses to work an account they can press a button from the patient table that will flag the account that it's ready to work and who accepted it to work. From there the script will take you to the working layout, which the source table is all accounts. I don't want them to see all accounts only the accounts that have been flagged to be worked plus I want it to find the related record. I seem to have these steps working my concern is if the worker wanted to do a find, then I want that find to always constrain that find to accounts that have been indicated ready to work, which I have a field for this. So that means I will need to replace the perform find to my added constrain find. I hope this make sense...

        • 1. Re: Custom Buttons
          philmodjunk

          If you have FileMaker Advanced, you can set up a custom menu where the original menu option--such as perform find now performs a script of your own choosing, but you don't need to do that to get the results that you have requested here.

           

          Set up the OnModeEnter layout to perform a script on the layout each time that the user enters Browse mode writtend something like this:

           

          Enter Find Mode [ ] --No pause, no stored criteria

          Set Field [ YourTable::Field ; "=1"]
          Constrain Found Set [ ]

           

          This will constrain the found set after every time that the user performs a find after their records have been found and the user returns to browse mode.

          1 of 1 people found this helpful
          • 2. Re: Custom Buttons
            cisaac

            Thank you for you advice, I'm finding that this option is causing my script to be stuck in a loop on that layout. Also if I enter that layout with out a perform find it will indicate that nothing was found and wants me to modify my find. Is there an If then statement that I could use in this script to prevent it from getting stuck in the internal loop.

            • 3. Re: Custom Buttons
              philmodjunk

              Hmm, I forgot that this script will trip it's own trigger. There's a way to script around that and a way to hide that error dialog:

               

              If [ $$TriggersOff ]

                 Exit Script [ ]

              End If

              Set Variable [$$TriggersOff ; value: True ]
              Enter Find Mode [ ]

              Set Field

              Set Error Capture [on]

              Constrain Found Set

              Set Variable [$$TriggersOff ; "" ]

               

              The $$TriggersOff variable keeps the script from getting trapped in a loop.

              Set Error Capture keeps the "no records found" dialog from interrupting the script.

              • 4. Re: Custom Buttons
                cisaac

                Just to confirm, wouldn't I need to set the Variable before the if then statement?

                • 5. Re: Custom Buttons
                  philmodjunk

                  No you do not. 

                   

                  You only want to exit the script like this, the second time around. The variable is set to a value the first time the trigger is tripped. Then it exits without doing anything, when the script trips its own trigger--eliminating the infinite loop.

                   

                  The final step returns the global variable back to it's original null state.

                   

                  This is a method that I frequently use to keep scripts from tripping script triggers during script execution. I put that If block at the beginning of all trigger performed scripts.

                  • 6. Re: Custom Buttons
                    cisaac

                    I'm having a no luck with this script and might have to abandon it, but I was debugging the script and keep noticing that the script is putting 0 in the set field vs a 1 which is what is coded. I have never seen that before and that might not be something you can help with.

                     

                    • 7. Re: Custom Buttons
                      philmodjunk

                      Your set field step is not correct. you have set up an expression that compares the value of the field to 1 while in find mode. This will never be true and thus evaluates to 0 (false). This value is then entered as find criteria.

                       

                      Compare that step to mine that I am pasting here from one of my earlier replies:

                       

                      Set Field [ YourTable::Field ; "=1"]

                      • 8. Re: Custom Buttons
                        JackRodges

                        Your constrain should be after the find is performed.

                         

                         

                        Enter Find Mode

                        set field( fieldname ; 1 )

                        Perform find

                        Constrain found set to xxxx

                        • 9. Re: Custom Buttons
                          philmodjunk

                          Not in this case.

                           

                          The script is set to run via script trigger after the window returns to Browse mode. That means that it runs after any find performed either manually or via script.