Skip to main content



No record found.

Business Central forum
Suggested answer

Scan items instead of using Item Number

Posted on by 7
Frustrated BC user here. I am looking to do a very simple task. I want to add a field (/Barcode/) to certain tables (Item Table [shown below], Production BOM Lines, etc.). Instead of selecting the Item Number, I would like to scan the item (using Item Reference Table) with my scanner. This is becoming incredibly complicated to do something so simple. 
I can't add the field through Design or Personalize as the existing tables don't contain the Item Reference fields. I've tried approximately 80 combinations of AL code, none which satisfy what I'm trying to do. Flow Fields, Table Relations, actions, triggers, pulling my hair - none have worked.
After reading, re-reading, and re-re-reading AL Dev guide, I just cannot understand how, when, where, or why to use a trigger, a validation. I've coded in Python for quite a few years at a basic level, but for some reason doing simple tasks in AL is monumental for me. To me, AL is just downright confusing and non-sensical, and Microsoft's website doesn't help whatsoever and if anything, is more confusing.
For example, on the table extension I created for Item, the field is not automatically populating - I have to use the drop down and manually select the item number, which it then populates (see screenshot). In addition, on Production BOMs, the inverse does not work either (e.g., scan the barcode to populate the Item Number, Description, UoM, etc.) - I must select the item number first, which then makes my whole idea pointless. 
Thanks you for any advice,
Code (50105 is Item TblExt and 50104 is Production BOM Line TblExt): 
tableextension 50105 ItemExtension extends Item
field(50105; Barcode; Code[50])
Caption = 'Barcode';
DataClassification = CustomerContent;
ExtendedDatatype = Barcode;
TableRelation = /Item Reference/./Reference No./ where(/Item No./ = field(/No./));
tableextension 50104 BOMTableExtension extends /Production BOM Line/
field(50104; ItemReferenceNo; Code[50])
Caption = 'Item Reference No';
DataClassification = CustomerContent;
ExtendedDatatype = Barcode;
TableRelation = /Item Reference/./Reference No./ WHERE (/Item No./ = field(/No./));
/*trigger OnValidate()
ItemRef: Record /Item Reference/;
if Type = Type::Item then
ItemRef.SetRange(/Item No./, /No./);
if ItemRef.FindFirst() then
ItemReferenceNo := ItemRef./Reference No./
  • Suggested answer
    Ben Baxter Profile Picture
    Ben Baxter 4,263 Super User on at
    Scan items instead of using Item Number
    I don't think you need to program anything here.  The out-of-the-box capability should work for you.
    You don't need to add a field to the Item Card, in fact this may cause issues for the User if the data doesn't make it to the Item Reference table.  Enter the Barcode value in the Item Reference table as a Type = Barcode.  On the Component Journal, display the Item Reference No. field.  When scanning the barcode ensure you are on the Item Ref. Field.  The system will receive the input and lookup the related Item.
    Before you spend a lot of time programming this, if your scanner is a handheld scanner (not USB/Bluetooth), you should look up the ISV Extensions for this functionality.  Your partner may already have a preferred solution they can recommend to you.
    I hope this helps resolve your issue, if so please mark it as a Verified Answer to help other forum users.
    Best Regards,
    Ben Baxter
    Accent Software Inc

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,513 Super User

Martin Dráb Profile Picture

Martin Dráb 225,862 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans