1 2 Previous Next 17 Replies Latest reply on Mar 22, 2012 1:51 PM by hobbiesdeveloper

    Script Trigger onObjectExit Go To Field not working

    hobbiesdeveloper

      Title

      Script Trigger onObjectExit Go To Field not working

      Post

      Hello,

      Below is a script i have deployed to a container field in filemaker which loops through each line of text and adds the "*" to each beggining of line but for some reason it keeps coming back to the script due to the Script Trigger triggering the script again without my permission. I tried to use the Go to Field option to bypass the script trigger on that container after the script has run once but the Go to Field does not work.

      I have attached the script screenshot:

      Please help me find out how to us the Go to Field properly?

      picture.jpg

        • 1. Re: Script Trigger onObjectExit Go To Field not working
          philmodjunk

          It appears that you are attempting to use the $$no_trigger global variable to keep the script from tripping its own trigger. But the first line of your script turns off the trigger before it can check the value of this variable. I suggest removing or disabling this script step.

          • 2. Re: Script Trigger onObjectExit Go To Field not working
            hobbiesdeveloper
             I have removed the trigger but it's still keeps running the script on and on. It looks like im stuck in the container and not able to go to a different field while still running the script.
            • 3. Re: Script Trigger onObjectExit Go To Field not working
              philmodjunk

              On which field is the trigger set?

              Try enabling the script debugger and performing your script, then step through it line by line. This can often be an eye-opener with this type of script as you will be able to see exactly where your cursor is and what values are in fields and variables (use the data viewer) at each step.

              • 4. Re: Script Trigger onObjectExit Go To Field not working
                hobbiesdeveloper

                I tried to view the code step by step using the Data Viewer and looks like whenever I try to leave the current container where the Trigger Script Started it re-genarates the script again after leaving the current field container, not sure why it's running the script again even after i leave the current field?

                Thanks.

                • 5. Re: Script Trigger onObjectExit Go To Field not working
                  philmodjunk

                  What is the name of the field on which you have set this trigger? Products::Features?

                  "Container" is a specific type of field. You appear to be modifying the contents of a text field--not a container field.

                  What value do you see in the $$no trigger variable when you step through the script? Once that value is set to True, it should keep the continuous chain of triggers from happening, but you should still see one trip of this trigger (but with the If step keeping anything from happening) for each time your script loops.

                  I can think of a simpler, non looping way to insert the * bullet points:

                  Set Field [ Products::Features ; "*" & Substitute ( Products::Features ; ¶ ; "¶*" )

                  It should trip any triggers as set field  makes changes at the data level instead of interacting with your layout, but it doesn't explain why your current script is tripping the OnObjectExit script trigger.

                  • 6. Re: Script Trigger onObjectExit Go To Field not working
                    hobbiesdeveloper

                    Yes, it is Products::Features text field.

                    I do apologize it is a text field not a container field.                                                                                                                             

                    It is set to true after the if [not $$no_trigger]

                    and set to false once the if [IsEmpty ($line)] is true.

                    Everytime i try to click anywhere else from the text field it re-activates the script.

                     

                    • 7. Re: Script Trigger onObjectExit Go To Field not working
                      philmodjunk

                      It is set to true after the if [not $$no_trigger]

                      and set to false once the if [IsEmpty ($line)] is true.

                      Yes, but the second line should not execute each time as the If step at the beginning should prevent that. Instead, you should see this script pop up, hit the If step and exit each time the script trips this same trigger.

                      Everytime i try to click anywhere else from the text field it re-activates the script.

                      As it should--since that exits the field and thus trips the script trigger. If you want to only perform the script when it is exited from a keyboard action (tab, enter, Return) and not from a mouse action, you should use a different trigger than the OnObjectExit trigger.

                      • 8. Re: Script Trigger onObjectExit Go To Field not working
                        hobbiesdeveloper

                        Which Trigger would you recommend me running and how would i make sure that it would not re-run the script on trigger. I would like to be able to run the script once after the list of features are listed in the text field but not to re-run the script, do you have any advise to have this way?

                        • 9. Re: Script Trigger onObjectExit Go To Field not working
                          hobbiesdeveloper

                          I also removed the Set Variable ( $$no_Trigger ; Value:False ) in the if( IsEmpty (&line ) but now the script doesn't get activated, looks like the first line Set Variable ( $$no_trigger; Value:True ) was set to True and when it tries to exit there is nothing telling it to switch it back to False. The script only runs if &&no_trigger is false.

                          • 10. Re: Script Trigger onObjectExit Go To Field not working
                            philmodjunk

                            $$no_trigger is a global variable. It retains it's value after the script completes execution. You need that in order for it to work. You need a step like the one you had that sets it back to false or this will run only once--the first time your run the script after opening the file and never again after that.

                            One simple (possibly too simple) way to limit when this script is executed is to use the OnObjectSave trigger. This trigger will trip each time you modify the contents of the field and then exit it. Simply clicking in and out of it will not trip the trigger. But this may still create an issue for you as you wouldn't want a second set of bullets inserted if you just corrected the spelling in one word.

                            I suggest you use this code To "bullet format" the text and eliminate your current loop altogether:

                            Set Variable [ $noBullets ; Let ( [ t = Products::Features ; nb = Substitute ( t ; ¶* ; "¶" ) ; L = Length ( nb ) ] ; Right ( nb ; L - 1 ) ]
                            Set Field [ Products::Features ; "*" & Substitute ( $noBullets ; ¶ ; "¶*" ) ]

                            The first line removes any bullets added by a prior call to this script and the second line re-inserts them.

                            Note: since Features appears to store a list of items, you might be better off storing your feature list as a set of related records instead of all in one field like this. That can make it much easier to manage any special formatting such as the addition of "bullet" characters to the beginning of each line.

                            • 11. Re: Script Trigger onObjectExit Go To Field not working
                              hobbiesdeveloper

                              I will definitely give these steps a try.

                              Thank you so much for all your great work.

                              • 12. Re: Script Trigger onObjectExit Go To Field not working
                                philmodjunk

                                Hmmm, just spotted a problem. This suggested use of Substitute will delete the first character of the text even if it is not a "*" character.

                                Set Variable [ $noBullets ; Let ( [ t = Products::Features ; nb = Substitute ( t ; ¶* ; "¶" ) ; L = Length ( nb ) ] ;
                                                                             If ( Left ( nb ; 1 ) = "*" ; Right ( nb ; L - 1 ) ; nb ) ]
                                Set Field [ Products::Features ; "*" & Substitute ( $noBullets ; ¶ ; "¶*" ) ]

                                • 13. Re: Script Trigger onObjectExit Go To Field not working
                                  hobbiesdeveloper

                                  Would you be able to help me get the related records to work, not really sure how to proceed on my end in getting the Features section list stored as related records?

                                  • 14. Re: Script Trigger onObjectExit Go To Field not working
                                    philmodjunk

                                    How familiar are you with portals?

                                    a portal of related records might look like this:

                                    Features:

                                    • Faster than a speeding bullet
                                    • Stronger than a Locomotive
                                    • Leaps tall buildings in a single bound

                                    Each row of text is a record in a related table and Your portal lists them out and permits editing them.

                                    You can put a bullet character as layout text to the left of the text field inside the portal row and each feature will automatically show the leading bullet character you want without needing to use any scripting to make it happen.

                                    1 2 Previous Next