Hi-
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,
Nick
Code (50105 is Item TblExt and 50104 is Production BOM Line TblExt):
tableextension 50105 ItemExtension extends Item
{
fields
{
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/
{
fields
{
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()
var
ItemRef: Record /Item Reference/;
begin
if Type = Type::Item then
begin
ItemRef.SetRange(/Item No./, /No./);
if ItemRef.FindFirst() then
ItemReferenceNo := ItemRef./Reference No./
end;
end;*/
}
}
}