Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Table creation

Posted on by 97

Hi All,

I'm trying to create a New Page from a New table.

The issue im having is t hat the fields do not populate themselves.

I require the following
Item
Description
SKU

Bin Code
 

This is my Table

table 50111 "X_Item Report"
{
    Caption = 'X_Item Report';
    DataClassification = ToBeClassified;

    fields
    {
        field(1; "Item No "; Text[100])
        {
            Caption = 'Item No ';
            DataClassification = ToBeClassified;
            TableRelation = Item."No.";
        }
        field(2; Description; Text[200])
        {
            Caption = 'Description';
            DataClassification = ToBeClassified;
            TableRelation = Item.Description where(Description = field("Item No "));

          
        }
        field(3; SKU; Code[50])
        {
            Caption = 'SKU';
            DataClassification = ToBeClassified;
            TableRelation = "Stockkeeping Unit"."Item No." where("Item No." = field("Item No "));
        }
        field(4; "Bin"; Text[100])
        {
            Caption = 'Bin of last occurance';
            DataClassification = Tobeclassified;
            TableRelation = "Bin Content"."Bin Code" where("Item No." = field("Item No "));
        }
    }
    keys
    {
        key(PK; "Item No ")
        {
            Clustered = true;
        }
    }
}

I tried using a trigger, however it doesn't seem to be picking up the fields.

This is the trigger i tried using for the description

  trigger OnValidate()
            var
                recDesc: Record "Item";
            begin
                if "Item No " = "Item No "
                then
                    if recDesc.get("Description") then begin
                        "Description" := "Description"
                    end;
            end;

Any assistance would be greatly appreciated

  • rajivsewsarran Profile Picture
    rajivsewsarran 97 on at
    RE: Table creation

    tableextension 50120 Bin extends Item
    {
        fields
        {
            field(50120; Bin; Code[30])
            {
                TableRelation = "Bin Content"."Bin Code" where("Item No." = field("No."));
                Caption = 'Bin';
                DataClassification = ToBeClassified;
            }
        }
        local procedure YIR(var Item: Record Item; LocationCode: Code[10]; VariantCode: Code[10])
        var
            Bin: Record "Bin Content";
        begin
            if item.get("No.") then
                if Bin.get(LocationCode, Item."No.", VariantCode) then begin
                    Bin."Item No." := Bin."Bin Code";
                    item.modify;
                end;
        end;
    }
    
    
    
    
    pageextension 50120 Bin extends "Item List"
    {
        layout
        {
            addafter(Type)
            {
                field(Bin; Rec.Bin)
                {
                    ApplicationArea = all;
                    Caption = 'Bin';
                }
            }
        }
    }

    Hi Nitin,

    thanks again for your help with this.

    I tried applying the same logic getting the "Bin Code" from the "Bin Contents" table but it doesn't seem to work either

    I still cant see what im doing wrong.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Table creation

    Hi rajivsewsarran

    Please try below

    tableextension 50113 SKU extends Item

    {

       fields

       {

           field(50113; SKU; Code[30])

           {

               TableRelation = "Stockkeeping Unit"."Location Code" where("Item No."= field("No."));

               Caption = 'SKU';

               DataClassification = ToBeClassified;

           }

       }

       local procedure YIR(var Item: Record Item; LocationCode: Code[10]; VariantCode: Code[10])

       var

           SKU: Record "Stockkeeping Unit";

       begin

           if item.get("No.") then

               if SKU.get(LocationCode, Item."No.", VariantCode) then

    begin

                   Item."Shelf No." := SKU."Shelf No.";

    item.modiy;

    end;

       end;

    }

  • rajivsewsarran Profile Picture
    rajivsewsarran 97 on at
    RE: Table creation

    This is what i have so far , that doesn't work

    tableextension 50113 SKU extends Item
    {
        fields
        {
            field(50113; SKU; Code[30])
            {
                TableRelation = "Stockkeeping Unit"."Location Code" where("Item No."= field("No."));
                Caption = 'SKU';
                DataClassification = ToBeClassified;
            }
        }
        local procedure YIR(var Item: Record Item; LocationCode: Code[10]; VariantCode: Code[10])
        var
            SKU: Record "Stockkeeping Unit";
        begin
            if item.get("No.") then
                if SKU.get(LocationCode, Item."No.", VariantCode) then
                    Item."Shelf No." := SKU."Shelf No.";
        end;
    
    }
    

  • rajivsewsarran Profile Picture
    rajivsewsarran 97 on at
    RE: Table creation

    ok, so ive sorted that , simple errors on my part.

    Now i've created a table extension to extend the "Item" table with the field "Stockkeeping Unit"

    I need this to look at the item number and populate the field.

    This is what i used, can someone tell how where i went wrong?

    tableextension 50113 SKU extends Item

    {

       fields

       {

           field(50113; SKU; Code[30])

           {

               TableRelation = "Stockkeeping Unit"."Location Code" where("Location Code" = field("No."));

               Caption = 'SKU';

               DataClassification = ToBeClassified;

               trigger OnValidate()

               var

                   RecSKU: Record "Stockkeeping Unit";

               begin

                   if xRec."No." = Rec."No."

                   then

                       if recSKU.get(SKU) then begin

                           SKU := rec.SKU

                       end;

               end;

           }

       }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans