Scripting a field

I would like to script a field to automatically count the number of layout pages in existence for a particular serial number.
I am familiar with writing scripts for buttons that could accomplish this but how do you script a FIELD to automatically do this?
I tried the Get(Count) and it just gives me the count of ALL the records for this layout.

Who is Participating?
You can't define a field to be the result of a script, that's not possible in FileMaker.

>I would like to script a field to automatically count the number of layout pages in existence
>for a particular serial number.

Not exactly sure what you mean by this. If your goal is just to calculate the number of records that have a certain value in a field, then you can use the count() function to do this, by referring to the field you want to count through a relationship. Create a relationship between a field containing the value you want to identify, and the field you want to count. This can be a self-join relationship based on a global field. This is a standard technique for counting records which meet certain criteria.

If you're talking about counting printed pages in a report, you'll definitely need to use a script for that, as there's no way to do this with a calculated field. What you can do is create a script that counts the pages and stores that value in a field, and then use a third-party plugin to execute your script whenever some calculation is evaluated. This might be helpful in your situation. Here's a plugin you can try...

With FileMaker Advanced, there's also the option to define Custom Functions. These will allow you to do a limited form of "programming" in a field definition by using logical functions and recursion. It's quite powerful, however it's restricted to working with fields and values. It cannot interact with the user interface in any way, so it may not be helpful if you're trying to count pages.


I think he means to count printed pages for a given found set.
the idea (2nd idea from Bill) is to search for the required found set of records, goto preview mode, goto last page, store the page number in a variable (there is a get function for this), then store it back in the field where you need it. no other way, and if that is 500 pages, I would not use the event plug-in to calculate it automatically because its gonna be slow, I would do it on purpose only.
nravidaAuthor Commented:
OK, I guess I just wanted to make sure scripting a field was or was not a possibility.
Thanks for the other hints. I am almost finished with my database thanks to everyone's help :) and my boss is pretty happy with that.  
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.