You could use the "OnObjectEnter" script step to checks for your condition when a user tries to activate the drop down field, and then uses "Go To Object" to go to a different object if the condition is invalid. IE, you force them to not be able to access the field via script trigger based on your condition. Make sure your script has an "allow user abort - OFF" script step in there as well.
1 of 1 people found this helpful
That wont quite work. The OnObjectEnter trigger doesn't fire on a pop-up menu or drop-down list until after the menu/list closes (either by the user making a selection or clicking on a blank part of the layout, leaving the field active).
The "data separation model" means different things to different people, but most interpretations I know of don't create any reason to put more logic in scripts vs. schema. Certainly many folks who use separated file architectures also aspire to put as much logic in scripts as possible, but the latter does not necessarily follow from the former. What is the condition in which users should be able to edit the field? It might be more appropriate to make the field inaccessible under that condition using FileMaker's native security features (in the data file). Note that security at the record level can be determined by calculation, but security at the field level cannot. It might be worth considering spinning that field off into a separate table with a one-to-one relationship with the portal table to take advantage of security based on a calculated condition.
If really want to stick to scripting, you can take advantage of the quirky order of operations for the OnObjectEnter trigger:
- The user clicks on the field
- The script parameter calculation evaluates
- The pop-up menu displays
- The user makes a selection
- The triggered script fires with the parameter set in 2.
Using this, you can capture the original value of the field with the script parameter, and set it back in the triggered script:
Get ( ActiveFieldContents )
# Exit disabled trigger, per best practices
Exit Script [True]
If [not IsEmpty ( Get ( ScriptParameter ) ) // or use your own condition here]
# Don't specify the field, so the step will target whatever the active field is
Set Field [Get ( ScriptParameter )]
Exit Script 
an other method you could use is to disable access to the popup field and put a button on to of the field.
If the button is pressed and the conditions are met, you can use the go to popup field step to open the popup menu.
Hope that helps,
Ruben van den Boogaard
you're right, I didn't register that Xavier noted that he wanted a popup.
If drop downs are acceptable though, here's a demo of that trigger (which DOES work on drop down menus).
OnObjectEnter_Menu.fmp12.zip 11.0 K