OnObjectEnter is a "post" script trigger, meaning it will execute after the event has been processed. You want a "Pre" script trigger maybe try OnObjectCommit. The user will be able to change the field but before the change is committed it the script trigger will fire. The attached script can then revert the record if the field is suppose to be locked.
Another idea, if the field is locked for all records then change the field behavior so that it can't be entered in Browse mode. Add a tool tip that tells the user the field is locked.
Another option if no apropriate pre-event script trigger is found would be to go back to the pre-trigger days...
Make the radio button selections buttons which fires scripts of the type:
If [Lockfield = "Unlocked"]
SetField [RadioField ; "Desired value"]
How can I prevent changes to this field?
You CAN use the OnObjectEnter trigger, passing as Script Parameter the field's value.
The script will be something like this:
Set Field [ YourField ; Get ( ScriptParameter ) ]
Commit Records/Requests [ ]
Contributors, I apolize for taking up your time. The problem is a recurring Trim(ID 10 T) error. My record lock function works just fine when I am logged in with the correct privilege set on any style field. I thought I was having this problem while logged in with [full access].
I am still having trouble consistenly intercepting the unfriendly messages with my "Click the padlock to unlock the record" dialog. My interceptor script works fine for edit fields, but not for drop down lists, radio buttons, calendars, and such.
The OnRecordCommit trigger will not let me relock when desired changes are made because I have to modify data on the record to set the lock flag. Thanks for your suggestions!
If [ Let (
key= Code (Get(TriggerKeystroke));
key=9 or key=10 or key=28 or key=29 or key=30 or key=31) ]
#do nothing; certian keystrokes are allowed
Else If [ Items::Lock=0 ]
Show Custom Dialog [ Title: "Record is locked"; Message: "Click on the lock below to make changes"; Buttons: “OK” ]
Exit Script [ Result: 0 ]