Jump to content
Server Maintenance This Week. ×

Unexpected Behavior: On Object Modify Script Trigger on Pop Up Menu OR Drop-Down Menu field


Recommended Posts

Hi all,

I have a Pop Up Menu attached to a field where a User selects an value from a related table. This works just fine.

However, I have a situation where I need to clear the value of some other fields if a User CHANGES their original selection in this Pop Up Menu.

I thought the best way to handle this would be to create a script that goes through each field that needs to be cleared-out by using a set field script step with a value of "" - to clear them. Then attached the Pop Up Menu field with a script trigger that activates the script just described.

This script attached using "onObjectModify" script trigger works partially, but not completely. If the User selects the pop-up menu and does NOT change the value. The script still runs. The User has not modified the value - but it is still firing off. This is not the behavior I would expect as the value did NOT change.

I have tried changing it to a drop-down menu to see if it was a bug with the Pop-up, but it seems to run the script if a user selects the same value that was their to begin with.

What am I doing wrong?

Side note: when I originally thought how to handle clearing other field values if the User came back and changed this one particular field value - I thought I should grab the fields current ID value, then compare it to what the User selected, if the values were the same no script would run to clear those other fields. If the comparison should they were different, then the script would run and clear those other fields.

In either approach, I would like the OnObjectModify trigger to work as I thought it was supposed to work.

Any help appreciated, thanks.

Link to comment
Share on other sites

When you reselect the existing value from a value list, the field (and the record) is modified. It is the equivalent of selecting the existing value and pasting over it. Filemaker does not compare the old value to the new; it merely registers an action.

The good news is that you can do the comparison yourself. Pass the existing value to the script as the script parameter, then have your script compare it to the current value of the field. If they are same, then no action needs to be taken - see the attached demo.

This method can be generalized to act on more than one field by using Get ( ActiveFieldContents ) to get both the "before" and "after" values. 

 

 

OnModifyBeforeAfter.fmp12

Edited by comment
  • Like 1
Link to comment
Share on other sites

Hi Comment,

Thank you so much: this did exactly what I needed to do!

I appreciate your help and the time you took to make the demo file: the demo file helped me reconstruct the functionality I needed.

Your explanation on how Filemaker treats the "OnObjectModify" script trigger was very helpful for me to understand the "why" aspect.

 

 

   

Link to comment
Share on other sites

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.