I added a “New” button to my controller. I noticed, however, that when the button is clicked and the “New” method runs, it doesn’t trigger the onNewCmd event for forms where that’s set.
Is there a way to have the one common method on the controller add a record, but also tell it to trigger the onNewCmd event if one is specified for the current form?
What you call the onNewCmd event is not an event (or maybe you can call it an event, I don’t know). What this does is ‘capturing’ the menu choice ‘new’ or the equivalent command key that creates a new record and replaces it with your method.
If I want to put a “New” button on the controller, is there any way to have it run the onNewCmd method of the current form?
I’m trying to avoid the following workarounds: Putting a “New” button on every layout, or having the “New” button method say “if contacts form, do this; if customer form, do this; if bills form, do this…”
I’d rather have the button do the exact equivalent of “Ctrl + N”, and then manage special cases at the form level. (Actually, truth be told, I’d like the users to just use the keyboard or menu, but the client wants pretty buttons. )
If it can’t be done, I can work around as above, and maybe beg for a feature in a later release, but I don’t want to go the long way around if the preferred way works.
Of course, being shameless, I have one more thing to ask for.
Suppose I have a method in SOME forms called newRecord, but on others I just want to create a new record and be done with it. Is there a step I could use to find out whether the form has a ‘newRecord’ method? That way, if there’s not a specific method, I could just run the Global version.
If it’s just a matter of remembering to make a newRecord method for every form, that’s certainly acceptable. If there’s a way to check for the existence of methods on a particular form, though, this will open a whole realm of possibilities for dynamic branching by exception.
It would appear the code in my last post doesn’t work in Find mode. Oddly enough, in Find, the “In” function seems to return true no matter what method name is inserted.