Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Hello,

I would appreciate any help with this.

I have a script trigger, onObjectExit, for a text field on my layout. This field is a dependency for an unstored calculation field on a related table occurrence. So when the user is leaving this field my script triggers and I attempt to get the value of the related unstored calculation field but the value has not been updated yet. What is strange is that I have a text field on this same layout that is displaying this same calculation field and it is updated right before my script executes - I know that by running the script debugger. Is there a reason the calculated field would show as updated on my layout but not in my script run soon after? Is there a way to force it to recalculate in my script?

thanks for any input you may offer

Scott

Posted

You'll need to commit the record to save the value, then refresh the window and flush the cached join results.

Posted

Thanks Vaughan - that worked. However, now my only trouble is that the user can no longer revert the record. Too bad that scripts don't follow the same rules as layouts when referencing an unstored calculation; namely they are recalculated like you would expect. Doesn't seem consistent when the field on my layout that is mapped to that unstored calculation field is showing the updated value but my script from the same layout shows the cached value.

Thanks again for you help

Posted

There is no point complaining that FMP doesn't work as you'd expect: put your energy into learning how it DOES work.

FMP has been around for over 20 years: the current incarnation FMP 7+ since 2004. It does what it does the way it does it, and it works well.

Unstored calculations cannot keep recalculating themselves, otherwise the program would burn cpu cycles continuously and unnecessarily: unstored calcs have a trigger, and that trigger is committing the record and refreshing the window.

I'd suggest that whatever you are doing that relies on the unstored calculation might not be the best way of doing it. It's not a problem with FMP.

Posted

I don't really think I was complaining at all and I appreciate what FileMaker gives you for sure. However, to say someone shouldn't try to understand the underlying mechanisms but just do it is silly. Also, If the layout saw the need to recalculate to show the field correctly, it is not a long shot that a script in the same context should recalculate it also. Imagine a field showing one number and a trigger script on the same layout showing a different number - Inconsistent! In addition, it in not great that the programmer needs to commit when it totally negates the possibility of reverting other changes to the layout that came before this trigger script fired.

Posted

Have you tried using a different script trigger? Maybe OnObjectModify, OnObjectSave, or OnRecordCommit would get you the behavior you want.

What is strange is that I have a text field on this same layout that is displaying this same calculation field and it is updated right before my script executes - I know that by running the script debugger.

Actually, the script fires before you exit the field. See here.

This topic is 5332 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.