When a form is opened, I have to run a check. When it does not pass the check, I have to be able to cancel the opening of the form. Off course, the user shouldn't see the form (closing the form in the OnOpen trigger shows the form and then closes it again), so I think this has to happen in the OnInit trigger. But then, I get a strange error:
"The form does not recognize the control 1180040018"
Anyone got advice?
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
0
Comments
Instead on putting the trigger on Onopen what you could do is put the code on OnPush of the control. This way before going to the form you will check for the condition and flag a error message and you will not receive a control error.
Thanks
Best regards
Suresh.
What you say is exactly true, and probably, I will have to do it that way, but is has one major disadvantage:
You have to change all the code in all places where you open that form. E.g. when we are talking about the customer card form (and in my case, I AM talking about the customer card form), you notice that it is called in many places (contact card, customer list, menu, ... and god knows where else ...). So, if I could trigger it in the OnInit-trigger of the customer card itself, then I would cover all possibilities. This means I would have to change only one object, else a great number of objects.
Do you understand my problem?
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Couldn't you use the OnActivate() trigger? In this case you must record wether your code run once. This trigger runs every time the form gets the focus from an other or opened. So the only thing you have to do is to check if it't the first focus -after opening the form- and run your code. In this case you just have to modify the Customer card.
--
János Borsics