Here's one way: In layout mode, you can select the popover element (double click its trigger button for example), and on the popover setup dialog chose "Set Script Triggers...". From the next dialog you can select a script to trigger "OnObjectClose" "OnObjectExit". Select a script (that you will need to create) which clears the field(s) you wish cleared.
You can use the Set Field script step to set your field to "" (pair of double quotes with no space between) or set it to any other value you need. E.g. Set Field [myTable::myField ; "" ]
I use OnObjectOpen to clear the field each time the popover opens.
Phils reply jogged my memory a bit: The script trigger will be OnObjectEnter or OnObjectExit (either will work, depending on when you want the clear to occur). I'll edit my above reply to reflect the correction.
Additionally, you can use the "Clear" script step in a similar fashion, but I've had more reliable results with "Set Field" for some reason (but I haven't done comparisons recently).
1 of 1 people found this helpful
philmodjunk Other than being able to grab the last search string after a popover closes and, for example to set a variable and do something with it, is there an advantage to clearing on Enter rather than Exit? Just habit/personal preference? Something else that I'm missing?
My use of it on Exit has, in one particular case, been to have the popover open more smoothly (several fields to clear, plus some other steps), but I don't think I've noticed a difference in other cases. Just curious about your thoughts.
It's preference to a large part, but it also leaves the "last value" in that field after the find has been performed so that you can access it again. I sometimes need that find criteria for other uses--such as displaying the find criteria as part of the report that it produced or so that I can set up a "modify the last find" type capability.
About Clear vs. Set Field as options to clear the field.
There is one distinct difference between the two. Clear puts the cursor into the field that it clears. In fact, it won't clear the field at all if the field is not present on the current layout in order to do that. That's useful in this case since entering data into the field is likely to be the very next thing that you want to do after opening the popover, but this behavior can have unexpected side effects. You can actually use clear field to open a popover since putting the focus on an object in a popover panel opens the popover. The same thing can pop a tab or slide control panel to the front. It can also trip script triggers--which can be an undesirable result in some cases.
I once put Clear field in my script to clear a popover into my script and then discovered that clicking the popover button opened a completely different popover. That was due to using the same global field for temporary data entry (as you do here to set up a find request), in two different popovers. I ended up using set field to clear the field and go to object to put the cursor into the field.
2 of 2 people found this helpful
I just realized that I forgot the main reason I've gotten into the habit of clearing such fields "onObjectEnter". I support a complex, large scale solution that has several different developers working on it. Global fields in it are often tasked for different things on the same layout if "temporary data entry" is all that is needed. My story of the wrong popover opening is a case in point. So, at the time the user first opens the popover, that global field might have data in it left over from some other task. It might not be the case every time. It might be that a future change starts putting data in this global field as part of some other script.
So clearing the field "onObectEnter" is the only way to be absolutely sure that the user will not see data in the field that should not be there.
Thanks, Phil. All of your points make good sense. Thanks for sharing your preferences, experiences and use case(s).
Thanks to philmodjunk and dale_allyn for their help. the info provided helped me.
I have some problems with this, too. The Set Field-step works best OnObjectEnter, but there is a delay when you see the data in the search-field (not global) and the related records in the portal. The Clear Field-step is even worser, the records in the portal doesn't go away before the searc-field no longer is active. I can't see that Freeze or Refresh Window works with Popover windows, either.
I've also tried the Set Field-step with OnObjectExit, but since I'm using a button on the related records in the portal they are gone when the script runs.
It seems that the best way is to blank the search field OnObjectEnter. But how to make this "invisible" for the user?
Don't see what you are seeing. But you could set up a regular button to run a script that first initializes fields and then uses Go to object to open the popover.
I forgot to say that my database is on a server on a wireless network and maybe that could explain the delay. I'd think of an ordinary button, too, but then I presume it must be put on top of an "invisible" popover button...?
That would be one option. The simplest way is to set a Hide Object WHen expression on the popover button of True or the number 1. Then it's fully visible in Layout mode--which makes it easier to work with your layout.