6 Replies Latest reply on Apr 8, 2017 2:08 PM by philmodjunk

    Custom function in a calculated field, takes forever

    planteg

      Hi all,

       

      first a good advise to those who create Custom Functions: test them in the Data Viewer before using them in a calculated field, in a table that has 4700 records. How do I know ? Ya, you guest it .

       

      Since it's going to take forever, I force quit FMPA to end the torture, thinking I could the get back to my file and correct the Custom Function... Well when I reopen the file, FMPA remembers its was updating a calculated field and restarts the process.

       

      Is there some way I can have FMPA forget about the calculated field and let me work with the file ?

       

      Many thanks

        • 1. Re: Custom function in a calculated field, takes forever
          taylorsharpe

          If the Custom Function is calculating in the Data Viewer, force quitting it will forget that.  But if you put it in a field, it is not going to forget it.  The best you can do is try to change layouts to one not based on the troubled table or go to layout mode.  Once in another layout or layout mode, then manage database and delete the field.  If you have a script that runs and does something in another table, you could open the file with the FMP URL and run that script to change layouts runs and FM doesn't think about all fields in a layout when running a script.  So something like FMP://someURL.com/file.fmp12?script=somescript  It means you have to know the exact name of the script though. 

           

          Personally I would open it and hit command/control - L to go to layout mode and just wait for FM to quit thinking. 

           

          Maybe someone will have a better idea. 

          • 2. Re: Custom function in a calculated field, takes forever
            user19752

            I tested similar idea, using .fmpsl (snapshot link)

            Opening .fmpsl, layout went directly specified in it, at least onLayoutEnter trigger for the layout set in File option didn't fire.

            .fmpsl is text (XML) file, so you can make it from any file, then edit it for target file.

            1 of 1 people found this helpful
            • 3. Re: Custom function in a calculated field, takes forever
              planteg

              Hi Taylor and user19752,

               

              I will stop working with that file and work with a previous version, it's only a database to explore things, no real data.

               

              Back to my broken database, when the database open, there is no Layout displayed. The only windows displayed are the Launch Center and a dialog called Database Update telling Records remaining to process. FMPA does not accept keyboard our mouse entries.

               

              That's Ok, I learned two things: I am not that good at writing Custom Functions and I should test them properly !

              • 4. Re: Custom function in a calculated field, takes forever
                taylorsharpe

                Custom functions can be powerful and problematic.  I personally avoid them because I prefer to do most such things in scripts.  But there are times like in field calcs that a custom function will work and a script will not.  So they have their place.  But it is good to get a feel of how they work as well as what can break.  Just mark that up to another degree at the University of Hard Knocks!

                • 5. Re: Custom function in a calculated field, takes forever
                  planteg

                  So they have their place.  But it is good to get a feel of how they work as well as what can break.  Just mark that up to another degree at the University of Hard Knocks!

                   

                  Yes, my head is aching a lot ! I went back to the Training Series Advanced, and there is not a lot in there, unfortunately. Do you know where I could learn more about Custom Functions ? I feel that by trial, that may be a loooooooooooon way to learn.

                   

                  I found out CFExplorer, a bit old but still works, but that does not help me a lot.

                   

                  Thanks

                  • 6. Re: Custom function in a calculated field, takes forever
                    philmodjunk

                    You should not have much trouble with CF's so long as they are not recursive.

                     

                    Testing all complex calculations, whether SQL queries, custom functions or other expressions in the Data Viewer is a good idea.