7 Replies Latest reply on Feb 3, 2014 9:26 AM by philmodjunk

    Resetting field when record changes?



      Resetting field when record changes?



           I have a portal displaying file names. When the user clicks a row in this portal, I have set up a container field to display the file (images). This is done through a script, making changes in a table.

           Now, when the user uses the mousewheel to scroll through the records (browse mode, form view), the container field continues to display this image, while I would like to reset the field to display nothing (the image may not be associated with the new record).

           I have been lookign into script triggers to accomplish this clearing, but since the layout doesn't change I can't use the layout triggers. Likewise the object triggers fail me, since I don't want to reset the field whenever the user changes some field.

           So, I guess the question is if there are any ways to detect a change in the active record (and hook a script into that event), or some other way to accomplish this clearing of the image field.

           Thanks for your time.


        • 1. Re: Resetting field when record changes?

               OnRecordLoad will be triggered each time a new record becomes current. but if your container field does not have global storage and is not from a related table linked with the X operator, you should not see this image in every record of the found set and thus no scripting is needed.

          • 2. Re: Resetting field when record changes?

                 The OnRecordLoad worked like a charm, thank you. Not sure how I missed it in the first place, probably should call it a day soon ;-)


                 But this does present a new problem. I use the Clear step to clear the field, but this leave the field selected. So the user has to click somewhere in the layout before he can scroll on. I tried 'Set Selection' without specifying anything, but I guess that was a stretch anyway.


                 How I can tell Filemaker to not have any fields selected?

            • 3. Re: Resetting field when record changes?

                   Set Field [ YourTable::Field ; "" ]

                   will clear the field without putting the focus in the field. But I will repeat that this should not be necessary if you don't use a global field for this purpose.

              • 4. Re: Resetting field when record changes?

                     That worked like a charm. Thank you!


                     It is a global field. Used to be a calculation, but that wont let me change the field via scripts, and only calculations have the 'don't store' option. Seemed to me to be my only option when I need to set the field via scripts and want to keep storage as low as possible (when I can't tell it to not store the field at all).


                • 5. Re: Resetting field when record changes?

                       If your container fields have external storage specified or you use "store a reference" when inserting the image, the image file is not stored in your file at all and that should address your storage concerns. Then a container field that does not have global storage specified might be used and when the user scrolls to a different record, you won't see the same image in this field.

                       But please note that I know very little about your database so global storage may remain the better option. It just seems like you want a field with global storage to act as though it doesn't have global storage specified...

                  • 6. Re: Resetting field when record changes?

                         Thanks for your continued insights Phil :-)

                         You're right, I really don't want that field stored at all - but at the same time I want to be able to set the field via a script (which calculation type field does not allow).

                         I tried looking around for a 'store a reference' setting, but couldn't find anything like that. What / where are you referring to?

                    • 7. Re: Resetting field when record changes?

                           I have not once suggested that this be a field of type calculation. It can be a plain, simple container field with standard storage options. "store a reference" is an option that you select when inserting or importing the image into the container field in the first place. External storage is an option that became available for container fields with the release of FileMaker 12.