9 Replies Latest reply on Mar 20, 2014 1:07 PM by erolst

    cancel OnObjectEnter script

    raphthepenguin

      Hey there,

       

      I was wondering if there is a way to test the OnObjectEnter script before it runs?

      I have seen post that go in that direction and tried the approaches but my results where not what I hoped for.

       

      The OnObjectEnter is set to a Portal, and I would like to cancel/bypass it IF one of the fields is entered.

      Is there a way to do it.

       

      I found a workaround, to fill the whole portal with buttons but not where the fields are. And run the script from the buttons... But I wonder if their is a more elegant solution than filling my portal with lots and lots of buttons!

       

      Thanks

        • 1. Re: cancel OnObjectEnter script
          wimdecorte

          What object is the OnEnter enabled for?  The portal or just a bunch of fields in the portal.

           

          The OnEnter is a cancellable event but you can not "test it before it runs" - that part of your description is not very clear.

           

          If the user clicks in a field the OnEnter will fire.  Your script determines if it is OK for the user to be in that field at that time and you can cancel the event so that at the end of the event script, the user will NOT be in the field.

          • 2. Re: cancel OnObjectEnter script
            raphthepenguin

            The OnEnter is enabled for the portal.

             

            Therefore if I click on a field in the portal, it still runs, but I would like to cancel it if certain fields are entered.


            Sorry I hope thats more clear.

            • 3. Re: cancel OnObjectEnter script
              erolst

              Try using Get ( ActiveFieldName ) as first script step, then examine if the field name (if you get one) belongs to your verboten list; if so, use Commit and Exit Script (or whatever else you've planned).

              • 4. Re: cancel OnObjectEnter script
                raphthepenguin

                That seems to work.

                 

                Only one problem left:

                I have the calculation Get (ActiveFieldName) = "Field1" or "Field2" or "Field3" or "Field4"

                 

                The result is the whole thing only works with Field1, with the others it doesn't.

                How would I write out, my list in the calc that it works?

                 

                Thanks!

                • 5. Re: cancel OnObjectEnter script
                  siplus

                  IF 

                   

                  Patterncount(List("field1";"field2"...); Get(ActiveFieldName))

                   

                  Exit script(False)

                  1 of 1 people found this helpful
                  • 6. Re: cancel OnObjectEnter script
                    erolst

                    Two One problem with this approach – 1. FileMaker reads that expression differently than you intend, i.e. as Get (ActiveFieldName) = ( "Field1" or "Field2" or "Field3" or "Field4" ), and 2. G(AF) returns the fully qualified name, i.e. “PortalTOName::fieldName”.

                     

                    If you only want to check on the field name itself, tTry this:

                     

                    Let (

                    f = GetValue ( Substitute ( Get ( ActiveFieldname ) ; ¶ ; "::" ) ; 2 ) ;

                    not isempty ( FilterValues ( Get ( ActiveFieldname ) ; List ( fieldname1 ; fieldname 2 {; etc } ) ) )

                    )

                     

                    You could of course write

                    Get (ActiveFieldName) = "Field1" or Get (ActiveFieldName) = "Field2" or Get (ActiveFieldName) = "Field3" or Get (ActiveFieldName) = "Field4" ),

                    but that's a bit tedious …

                     

                    EDIT: oh well …

                    1 of 1 people found this helpful
                    • 7. Re: cancel OnObjectEnter script
                      raphthepenguin

                      I had to add a =1 at the end, so its a bolean, but that worked thanks!

                      • 8. Re: cancel OnObjectEnter script
                        raphthepenguin

                        I understand the 1. Problem, and I used sipluses Patterncount Idea to get past it.

                         

                        But the second problem I can not grasp, I placed a Custom Dialog in the Script that shows only G(AF) and the result was only the field name itself, thats why I only wrote that in the function.

                         

                        Thanks though! Now its working!

                        • 9. Re: cancel OnObjectEnter script
                          erolst

                          raphthepenguin wrote:

                          But the second problem I can not grasp, I placed a Custom Dialog in the Script that shows only G(AF) and the result was only the field name itself, thats why I only wrote that in the function.

                           

                          You're absolutely right – I was mentally at GetFieldname ( field ), which does return a fully qualified name …

                           

                          Sorry if I confused you. Good to see you got it working.