web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Table creation

(0) ShareShare
ReportReport
Posted on by 22

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

I have the same question (0)
  • rajivsewsarran Profile Picture
    22 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;

           }

       }

    }

  • rajivsewsarran Profile Picture
    22 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;
    
    }
    

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator 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
    22 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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,477

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 3,235 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,799 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans