You'll need to use other script triggers. For some triggers, FileMaker processes the "triggering event" first, then performs the script. For others, it performs the script then processes the triggering event. In the latter case, Exit Script [False] can be used to keep FileMaker from processing the triggering event. If you look up Script Triggers in FileMaker help, you can find a table where all triggers are listed and you can see which are "before" and which are "after" triggers.
OnObjectExit and OnObjectEnter are two "before the event" triggers that you might use--though I recognize that this still allows users to try to modify the field via drag and drop.
This isn't what I was hoping for. It won't allow me to show the custom dialog only when they try to edit what's there. I'd still like them to be able to enter the field, select what's there and copy the field contents to other fields if necessary. But with only OnEnter and/or OnExit, I don't think I'm going to be able to make it work like I want. I'll tinker with it, but may not be worth the effort.
Thanks for the detailed info.
1 of 1 people found this helpful
Then perhaps onObjectValidate might serve?
You might also look into OnRecordCommit
I'm taking a look at the chart you mentioned. I think the OnObjectKeyStroke may be the one that will work. I appreciate your input.
1 of 1 people found this helpful
arrow keys and things like ctrl-C are keystrokes a user might use to select and copy data, yet does not modify the field contents...
Oh yes. Hmm. Well, I've not given up yet.
Well, I got it to trigger when I wanted it to, but Get(LastError) = 9 doesn't catch it. You wouldn't happen to know which error code is tripped when trying to edit a record that has it's edit rule enabled do you?
Look up error codes in help.
Add a show custom dialog to show the value returned.
Make sure that you test for that error at the right time. Come to think of it "OnObjectValidate" will trip before the error and so you'd have to do a commit records with set error capture [on] before you could detect the privilege set error. Either that or replicate the test in the record level access expression as part of an if step in your script.
"Make sure that you test for that error at the right time. Come to think of it "OnObjectValidate" will trip before the error and so you'd have to do a commit records with set error capture [on] before you could detect the privilege set error. Either that or replicate the test in the record level access expression as part of an if step in your script."
If you have time, could you explain how to implement either of these approaches in a little more detail? I'm not following what you mean. I still haven't successfully figured out which error code I'm dealing with, or whether it can't be caught. Neither pre- nor post- script triggers seemed to work in catching what it is.
I tried to implement a SCD with a Get(LastError), but when triggered using the OnKeystroke, it showed a 0.
I switched it OnModify and then it never was fired.
Surely I'm not the first person to ever try something like this.
I understand this Mr Moyer, but when would this run? The script triggers I've tried haven't yet caught the one I'm looking for.
[do you] know which error code is tripped when trying to edit a record that has it's edit rule enabled...?
I think I understand - I was suggesting more of a catch-all net, instead of anticipating which error you might get ... just catch any error and examine it.
David and I have made the same suggestion: That you use Show Custom dialog to findout exactly what error is returned.
My other suggestion looks like this:
Set Error capture [on]
Commit Records [no dialog ]
Set variable [$Err ; Get ( LastError ) ]
If [ $Err > 0 ]
Revert Records [no dialog ]
Show Custom Dialog [ "Error: " & $Err ]
Once you know the error code, you can change or remove the show custom dialog step depending on what you want to do.
If [ Not //copy your record lock expression from Manage | Security here ]
Revert Record [No dialog ]
Do anything else that you want when they violate access permissions here