Not much information here. I tried the essentials of your script on a test file and it works OK. Try this test: change your script to find on a different field with simple content to search; this will indicate whether the script is capable of doing what you want.
Show custom dialog used like this usually has at least two buttons so that the user can choose to cancel out of the find. Each button you choose to use of the 3 possible can be set (or not be set) to commit records when the button is clicked. Did you select the "commit" option for the button that dismissed the dialog in order to perform the find?