I would like to know whether a certain field can be scanned through barcode scanner but cannot be input through keyboard for certain user but other user can be input the field through keyboard and scanner ?
Well, “normally” a barcode-scan just replaces the keyboard entry. So, if you disable a field for a certain user he will not be able to scan or to type in. But it depends on your scanner solution: if you could get the scanned value via a method or something, then you could handle everything with variables; which would you allow to disable a field for manual input … One small chance (have not tested) is the OnInputChange trigger of a textbox:
OnInputChange The C/AL code in this trigger is executed while the user makes entries into a text box. You can use this trigger to check the entries the user is making as he or she enters information. Applies to Text boxes Comments The system executes this trigger after it executes OnBeforeInput. It will continue to execute this trigger, after each keystroke, until the user finishes input. The system then executes the OnAfterInput trigger. If there is an error in the C/AL code you enter into this trigger, the system closes the form. You cannot use this trigger to write to the database.
The chance I see is “keystroke”, maybe there is a difference if you scan or type. If so, you could raise an error if a user is not allowed to type in … Hope this hels a little.
No,I have not solved my problem yet… Navision treat Barcode scanner = Keyboard so Oninputchange is same effect in Barcode scanner too… ???
If you have a OPOS compliant device this is not a problem. Unfortunately the NAvision implementation of an OCX does not allow to receive events. So you are having two options: 1st. : You implement that OCX and check with a timer if some data arrived [Quicker to implement but dirty] 2nd.: You are writing a wrapper application (or DLL) which can fire an event on the IDISPATCH. This application is then using the OPOS OCX and then you can fire an event once you receive an event from OPOS to Navision and perform the required action in the form. (Do not forget to set the “WithEvents” properties of the automation server variable to yes.
Oh yes, there would be another but tricky option [;)] If you can program your scanner so it sends : DATA then you can define a function key combination like Ctrl+Alt+F6 as Inside your Form your field is disabled. In a menubutton (small size, no border, showcaption=false) you define a menu item where you assign the same Shortcutkey. All this menuitem does is that it enables the field, and focuses on it. In the OnValidate trigger of the field you just disable it again. That should work as well.