Jump to content

Set Field in Find Mode


This topic is 8494 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi:

I'm a novice at scripting, but so far I've been able to solve most of my problems. Here is a problem, however, that I can't figure out. I have the following simple one-line script that works correctly in browse mode:

Set Field ["Notes", "LastName"]

When I change this script to the following, however, it fails:

Enter Find Mode[]

Set Field ["Notes", "LastName"]

When I run this second script, FileMaker goes to Find Mode and the cursor is in the first field on the layout. It appears that the Set Field script step doesn't run. Does anyone know why this isn't working?

When I created the second script, I received a confusing dialog box asking me whether I want to keep or replace data needed by the script. I don't understand this dialog, but regardless of how I answer it, the second script still fails.

Thanks, Keith Silva

Link to comment
Share on other sites

Set Field does work in Find Mode, but you can't reference regular fields. You can only reference constants (be they text or numbers) or global fields. This is because when you're in Find Mode you aren't in any particular record. If you try to reference a field that is specific to a record (unlike a global field) FileMaker doesn't know which data to use.

So, add a global field, which for my example, I'll call gTemp and rewrite your script as follows:

Set Field [ gTemp, Last Name ]

Enter Find Mode []

Set Field [ Notes, gTemp ]

Perform Find []

Now, the other part of your question, about the dialog asking if you want to keep or replace the find criteria, has to do with the fact that you have an Enter Find Mode script step. One of the options for this script step (which it doesn't appear you want to use) is to Restore Find Request. What this means is that you can enter Find mode, set up the search, perform the find and then go into ScriptMaker, open your script, close it and choose to replace the find criteria. If the Enter Find Mode has the Restore option set, when this script step is reached, the find criteria you set up will be restored. This can be useful if you want to build a custom find request that has a portion the same every time, such as finding all approved records within a certain date range. The approved portion stays the same, so you could save that portion of the find criteria and customize the date range portion.

Perform Find also has the option to save find criteria, but with that script you can't customize the find request.

There are other script steps that act like this, such as Sort, Page (or Print) Setup, Inport. Each of them has the option to restore the status of the function as it was before the script was created, or to replace it with the current status after the script has been created.

Chuck

Link to comment
Share on other sites

Chuck:

Thank you so much for the clear, thorough and timely answer. This was the first time I had to work with Find Mode in a script and I was not understanding the FileMaker help file and the book I'm using. Your answer really put things in perspective and now the help file and my book are a lot clearer! This weekend I'll make the necessary modifications including changing or adding some global fields. I was really stuck, but now I'm confident I can get this script to work. Like someone else on this forum said; I can't wait until I get good at this! Thanks again for your terrific help.

Regards, Keith Silva

Link to comment
Share on other sites

This topic is 8494 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.