Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Indexing Error message

(0) ShareShare
ReportReport
Posted on by 17

Hello,

I'm new in AL programming. I have created a table, card and list page for this table. I used no. series for the induvidual values in primary key field. When I want fill the database I got an error message bellow. I used page and table numbers within our lisence. Do you have any idea what is the problem? Thank you for your answer.

Table source code

table 50015 "SEI Planning Master Data"
{
    Caption = 'SEI Planning Master Data';
    DataClassification = ToBeClassified;

    fields
    {
        field(005; "PrimaryKey"; Code[35])
        {
            trigger OnValidate()
            begin
                if PrimaryKey <> xRec.PrimaryKey then begin
                    ManSetup.Get();
                    NoSeriesMgmnt.TestManual(ManSetup."Production plan nos");
                    "No. Series" := '';
                end;
            end;
        }
        field(010; "Plan_Name"; Code[6]) { Caption = 'Plan name'; }
        field(020; "Plan_UniqueID"; Code[35]) { Caption = 'Plan unique ID'; }
        field(030; "Plan_Version"; Integer) { Caption = 'Plan version number'; }
        field(040; "Plan_SalesLineOpenQty"; Decimal) { Caption = 'Original qty. of SO line'; }
        field(050; "Plan_PlannedQty"; Decimal) { Caption = 'Planned qty.'; }
        field(060; "Plan_FinishedQty"; Decimal)
        {
            Caption = 'Finished Qty.';
            
        }
        field(070; "Plan_RemainingQty"; Decimal) { Caption = 'Remaining qty.'; }
        field(080; "isProductionDone"; Boolean) { Caption = 'Production done'; }
        field(090; "Plan_UnitPrice"; Decimal) { Caption = 'Selling price'; }
        field(100; "Plan_PriceOfOriginal"; Decimal) { Caption = 'Selling price of original qty.'; }
        field(110; "Plan_PriceOfPlanned"; Decimal) { Caption = 'Selling price of planned qty.'; }
        field(120; "Plan_PriceOfRemaining"; Decimal) { Caption = 'Selling price of remaining qty.'; }
        field(130; "Plan_SH/Unit"; Decimal) { Caption = 'SH (Unit)'; }
        field(140; "Plan_SHOriginal"; Decimal) { Caption = 'SH for original qty.'; }
        field(150; "Plan_SHPlan"; Decimal) { Caption = 'SH for planned qty.'; }
        field(160; "Plan_SHRemaining"; Decimal) { Caption = 'SH for remaining qty.'; }
        field(170; "Plan_ETD"; Date) { Caption = 'Estimated date of delivery'; }
        field(180; "Plan_isSpecmat"; Boolean) { Caption = 'Special RM required'; }
        field(190; "Plan_Comment"; Code[100]) { Caption = 'Comment (max. 100 char.)'; }
        field(200; "Plan_ItemFG"; Code[20]) { Caption = 'Item number (Finished)'; }
        field(210; "Plan_Area"; Code[10]) { Caption = 'Production area'; }
        field(220; "Plan_SalesCode"; Code[10]) { Caption = 'Sales office code'; }
        field(230; "Plan_CustomerName"; Code[100]) { Caption = 'Customer name'; }
        field(240; "Plan_FGDCPrice"; Decimal) { Caption = 'FG standard cost'; }
        field(250; "Plan_FGDCforOrig"; Decimal) { Caption = 'FG standard cost for original qty.'; }
        field(260; "Plan_FGDCforPlanned"; Decimal) { Caption = 'FG standard cost for planned qty.'; }
        field(270; "Plan_FGDCforRemain"; Decimal) { Caption = 'FG standard cost for remaining qty.'; }
        field(280; "Plan_DC-SalesDiff"; Decimal) { Caption = 'Sales price - DC price'; }
        field(290; "Plan_RMCostPlanned"; Decimal) { Caption = 'RM cost for planned qty.'; }
        field(300; "Plan_WIP_0F"; Code[20]) { Caption = 'WIP level item number'; }
        field(310; "Plan_WIP_0P"; Code[20]) { Caption = 'WIP level item number'; }
        field(320; "Plan_WIP_0L"; Code[20]) { Caption = 'WIP level item number'; }
        field(330; "Plan_WIP_0G"; Code[20]) { Caption = 'WIP level item number'; }
        field(340; "Plan_WIP_0H"; Code[20]) { Caption = 'WIP level item number'; }
        field(350; "Plan_WIP_0J"; Code[20]) { Caption = 'WIP level item number'; }
        field(360; "Plan_WIP_0K"; Code[20]) { Caption = 'WIP level item number'; }
        field(500; "Plan_YearMonth"; integer) { Caption = 'YearMonth'; }
        field(510; "Plan_YearWeek"; integer) { Caption = 'YearWeek'; }
        field(520; "Plan_CreationDate"; integer) { Caption = 'Plan creationdate'; }
        field(530; "Plan_isModify"; Boolean) { Caption = 'A sor módosítva'; }
        field(540; "Plan_CreatedUser"; Code[40]) { Caption = 'Created by'; }
        field(550; "Plan_ApprovedBy"; Code[40]) { Caption = 'Approved by'; }
        field(560; "Plan_isApprove"; Boolean) { Caption = 'Plan approved or not'; }
        field(570; "Plan_Currency"; Code[3]) { Caption = 'Currency code'; }
        field(580; "Plan_ExchangeRate"; Decimal) { Caption = 'Exchange rate'; }
        field(590; "Plan_HCReq"; decimal) { Caption = 'Head count requirement'; }
        field(600; "No. Series"; Code[35])
        {
            Caption = 'No. Series';
            Editable = false;
            TableRelation = "No. Series";
        }

    }

    keys
    {
        key(PK; PrimaryKey)
        {
            Clustered = true;

        }


    }

    var
        NoSeriesMgmnt: Codeunit NoSeriesManagement;
        ManSetup: Record "Manufacturing Setup";

    trigger OnInsert()
    begin
        if PrimaryKey = '' then begin
            ManSetup.Get();
            ManSetup.TestField("Production plan nos");
            NoSeriesMgmnt.InitSeries(ManSetup."Production plan nos", xRec."No. Series", 0D, PrimaryKey, "No. Series");
        end;
    end;

    trigger OnModify()
    begin

    end;

    trigger OnDelete()
    begin

    end;

    trigger OnRename()
    begin

    end;
}

Card page source

page 50027 "SEI Planning Master data Card"
{
    PageType = Card;
    ApplicationArea = All;
    UsageCategory = Administration;
    SourceTable = "SEI Planning Master Data";
    Caption = 'SEI Planning Master Data';
    //Editable = true;
    //CardPageId = 50020;

    layout
    {
        area(Content)
        {
            group(PlanMasterData)
            {
                field(PrimaryKey; Rec.PrimaryKey) { }
                field(Plan_Name; Rec.Plan_Name) { Caption = 'Plan name'; ApplicationArea = All; }
                field("Plan_UniqueID"; Rec."Plan_UniqueID") { Caption = 'Plan unique ID'; ApplicationArea = All; }
                field("Plan_Version"; Rec.Plan_Version) { Caption = 'Plan version number'; ApplicationArea = All; }
                field("Plan_SalesLineOpenQty"; Rec.Plan_SalesLineOpenQty) { Caption = 'Original qty. of SO line'; ApplicationArea = All; }
                field("Plan_PlannedQty"; Rec.Plan_PlannedQty) { Caption = 'Planned qty.'; ApplicationArea = All; }
                field("Plan_FinishedQty"; Rec.Plan_FinishedQty) { Caption = 'Finished Qty.'; ApplicationArea = All; }
                field("Plan_RemainingQty"; Rec.Plan_RemainingQty) { Caption = 'Remaining qty.'; ApplicationArea = All; }
                field("isProductionDone"; Rec.isProductionDone) { Caption = 'Production done'; }
                field("Plan_UnitPrice"; Rec.Plan_UnitPrice) { Caption = 'Selling price'; }
                field("Plan_PriceOfOriginal"; Rec.Plan_PriceOfOriginal) { Caption = 'Selling price of original qty.'; ApplicationArea = All; }
                field("Plan_PriceOfPlanned"; Rec.Plan_PriceOfPlanned) { Caption = 'Selling price of planned qty.'; ApplicationArea = All; }
                field("Plan_PriceOfRemaining"; Rec.Plan_PriceOfRemaining) { Caption = 'Selling price of remaining qty.'; ApplicationArea = All; }
                field("Plan_SH/Unit"; Rec."Plan_SH/Unit") { Caption = 'SH (Unit)'; ApplicationArea = All; }
                field("Plan_SHOriginal"; Rec.Plan_SHOriginal) { Caption = 'SH for original qty.'; ApplicationArea = All; }
                field("Plan_SHPlan"; Rec.Plan_SHPlan) { Caption = 'SH for planned qty.'; ApplicationArea = All; }
                field("Plan_SHRemaining"; Rec.Plan_SHRemaining) { Caption = 'SH for remaining qty.'; ApplicationArea = All; }
                field("Plan_ETD"; Rec.Plan_ETD) { Caption = 'Estimated date of delivery'; ApplicationArea = All; }
                field("Plan_isSpecmat"; Rec.Plan_isSpecmat) { Caption = 'Special RM required'; ApplicationArea = All; }
                field("Plan_Comment"; Rec.Plan_Comment) { Caption = 'Comment (max. 100 char.)'; ApplicationArea = All; }
                field("Plan_ItemFG"; Rec.Plan_ItemFG) { Caption = 'Item number (Finished)'; ApplicationArea = All; }
                field("Plan_Area"; Rec.Plan_Area) { Caption = 'Production area'; ApplicationArea = All; }
                field("Plan_SalesCode"; Rec.Plan_SalesCode) { Caption = 'Sales office code'; ApplicationArea = All; }
                field("Plan_CustomerName"; Rec.Plan_CustomerName) { Caption = 'Customer name'; ApplicationArea = All; }
                field("Plan_FGDCPrice"; Rec.Plan_FGDCPrice) { Caption = 'FG standard cost'; ApplicationArea = All; }
                field("Plan_FGDCforOrig"; rec.Plan_FGDCforOrig) { Caption = 'FG standard cost for original qty.'; ApplicationArea = All; }
                field("Plan_FGDCforPlanned"; Rec.Plan_FGDCforPlanned) { Caption = 'FG standard cost for planned qty.'; ApplicationArea = All; }
                field("Plan_FGDCforRemain"; Rec.Plan_FGDCforRemain) { Caption = 'FG standard cost for remaining qty.'; ApplicationArea = All; }
                field("Plan_DC-SalesDiff"; Rec."Plan_DC-SalesDiff") { Caption = 'Sales price - DC price'; ApplicationArea = All; }
                field("Plan_RMCostPlanned"; Rec.Plan_RMCostPlanned) { Caption = 'RM cost for planned qty.'; ApplicationArea = All; }
                field("Plan_WIP_0F"; Rec.Plan_WIP_0F) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0P"; Rec.Plan_WIP_0P) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0L"; Rec.Plan_WIP_0L) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0G"; Rec.Plan_WIP_0G) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0H"; Rec.Plan_WIP_0H) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0J"; Rec.Plan_WIP_0J) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0K"; Rec.Plan_WIP_0K) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_YearMonth"; Rec.Plan_YearMonth) { Caption = 'YearMonth'; ApplicationArea = All; }
                field("Plan_YearWeek"; Rec.Plan_YearWeek) { Caption = 'YearWeek'; ApplicationArea = All; }
                field("Plan_CreationDate"; Rec.Plan_CreationDate) { Caption = 'Plan creationdate'; ApplicationArea = All; }
                field("Plan_isModify"; Rec.Plan_isModify) { Caption = 'A sor módosítva'; ApplicationArea = All; }
                field("Plan_CreatedUser"; Rec.Plan_CreatedUser[40]) { Caption = 'Created by'; ApplicationArea = All; }
                field("Plan_ApprovedBy"; Rec.Plan_ApprovedBy) { Caption = 'Approved by'; ApplicationArea = All; }
                field("Plan_isApprove"; Rec.Plan_isApprove) { Caption = 'Plan approved or not'; ApplicationArea = All; }
                field("Plan_Currency"; Rec.Plan_Currency) { Caption = 'Currency code'; ApplicationArea = All; }
                field("Plan_ExchangeRate"; Rec.Plan_ExchangeRate) { Caption = 'Exchange rate'; ApplicationArea = All; }
                field("Plan_HCReq"; Rec.Plan_HCReq) { Caption = 'Head count requirement'; ApplicationArea = All; }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action("Create New Plan")
            {
                ApplicationArea = All;
                Image = NewDocument;
                trigger OnAction()
                begin
                    Message('Hello');
                    CollectPlanData();
                end;
            }
        }
    }

    local procedure CollectPlanData()
    var
        SalesLine: Record "Sales Line";
        PlanData: Record "SEI Planning Master Data";
    begin
 


    end;
}

List Page source

page 50026 "SEI Planning Master data"
{
    PageType = List;
    ApplicationArea = All;
    UsageCategory = Administration;
    SourceTable = "SEI Planning Master Data";
    Caption = 'SEI Planning Master Data';
    Editable = true;
    CardPageId = 50027;

    layout
    {
        area(Content)
        {
            repeater(PlanMasterData)
            {
                field(PrimaryKey; Rec.PrimaryKey) { }
                field(Plan_Name; Rec.Plan_Name) { Caption = 'Plan name'; ApplicationArea = All; }
                field("Plan_UniqueID"; Rec."Plan_UniqueID") { Caption = 'Plan unique ID'; ApplicationArea = All; }
                field("Plan_Version"; Rec.Plan_Version) { Caption = 'Plan version number'; ApplicationArea = All; }
                field("Plan_SalesLineOpenQty"; Rec.Plan_SalesLineOpenQty) { Caption = 'Original qty. of SO line'; ApplicationArea = All; }
                field("Plan_PlannedQty"; Rec.Plan_PlannedQty) { Caption = 'Planned qty.'; ApplicationArea = All; }
                field("Plan_FinishedQty"; Rec.Plan_FinishedQty) { Caption = 'Finished Qty.'; ApplicationArea = All; }
                field("Plan_RemainingQty"; Rec.Plan_RemainingQty) { Caption = 'Remaining qty.'; ApplicationArea = All; }
                field("isProductionDone"; Rec.isProductionDone) { Caption = 'Production done'; }
                field("Plan_UnitPrice"; Rec.Plan_UnitPrice) { Caption = 'Selling price'; }
                field("Plan_PriceOfOriginal"; Rec.Plan_PriceOfOriginal) { Caption = 'Selling price of original qty.'; ApplicationArea = All; }
                field("Plan_PriceOfPlanned"; Rec.Plan_PriceOfPlanned) { Caption = 'Selling price of planned qty.'; ApplicationArea = All; }
                field("Plan_PriceOfRemaining"; Rec.Plan_PriceOfRemaining) { Caption = 'Selling price of remaining qty.'; ApplicationArea = All; }
                field("Plan_SH/Unit"; Rec."Plan_SH/Unit") { Caption = 'SH (Unit)'; ApplicationArea = All; }
                field("Plan_SHOriginal"; Rec.Plan_SHOriginal) { Caption = 'SH for original qty.'; ApplicationArea = All; }
                field("Plan_SHPlan"; Rec.Plan_SHPlan) { Caption = 'SH for planned qty.'; ApplicationArea = All; }
                field("Plan_SHRemaining"; Rec.Plan_SHRemaining) { Caption = 'SH for remaining qty.'; ApplicationArea = All; }
                field("Plan_ETD"; Rec.Plan_ETD) { Caption = 'Estimated date of delivery'; ApplicationArea = All; }
                field("Plan_isSpecmat"; Rec.Plan_isSpecmat) { Caption = 'Special RM required'; ApplicationArea = All; }
                field("Plan_Comment"; Rec.Plan_Comment) { Caption = 'Comment (max. 100 char.)'; ApplicationArea = All; }
                field("Plan_ItemFG"; Rec.Plan_ItemFG) { Caption = 'Item number (Finished)'; ApplicationArea = All; }
                field("Plan_Area"; Rec.Plan_Area) { Caption = 'Production area'; ApplicationArea = All; }
                field("Plan_SalesCode"; Rec.Plan_SalesCode) { Caption = 'Sales office code'; ApplicationArea = All; }
                field("Plan_CustomerName"; Rec.Plan_CustomerName) { Caption = 'Customer name'; ApplicationArea = All; }
                field("Plan_FGDCPrice"; Rec.Plan_FGDCPrice) { Caption = 'FG standard cost'; ApplicationArea = All; }
                field("Plan_FGDCforOrig"; rec.Plan_FGDCforOrig) { Caption = 'FG standard cost for original qty.'; ApplicationArea = All; }
                field("Plan_FGDCforPlanned"; Rec.Plan_FGDCforPlanned) { Caption = 'FG standard cost for planned qty.'; ApplicationArea = All; }
                field("Plan_FGDCforRemain"; Rec.Plan_FGDCforRemain) { Caption = 'FG standard cost for remaining qty.'; ApplicationArea = All; }
                field("Plan_DC-SalesDiff"; Rec."Plan_DC-SalesDiff") { Caption = 'Sales price - DC price'; ApplicationArea = All; }
                field("Plan_RMCostPlanned"; Rec.Plan_RMCostPlanned) { Caption = 'RM cost for planned qty.'; ApplicationArea = All; }
                field("Plan_WIP_0F"; Rec.Plan_WIP_0F) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0P"; Rec.Plan_WIP_0P) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0L"; Rec.Plan_WIP_0L) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0G"; Rec.Plan_WIP_0G) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0H"; Rec.Plan_WIP_0H) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0J"; Rec.Plan_WIP_0J) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_WIP_0K"; Rec.Plan_WIP_0K) { Caption = 'WIP level item number'; ApplicationArea = All; }
                field("Plan_YearMonth"; Rec.Plan_YearMonth) { Caption = 'YearMonth'; ApplicationArea = All; }
                field("Plan_YearWeek"; Rec.Plan_YearWeek) { Caption = 'YearWeek'; ApplicationArea = All; }
                field("Plan_CreationDate"; Rec.Plan_CreationDate) { Caption = 'Plan creationdate'; ApplicationArea = All; }
                field("Plan_isModify"; Rec.Plan_isModify) { Caption = 'A sor módosítva'; ApplicationArea = All; }
                field("Plan_CreatedUser"; Rec.Plan_CreatedUser[40]) { Caption = 'Created by'; ApplicationArea = All; }
                field("Plan_ApprovedBy"; Rec.Plan_ApprovedBy) { Caption = 'Approved by'; ApplicationArea = All; }
                field("Plan_isApprove"; Rec.Plan_isApprove) { Caption = 'Plan approved or not'; ApplicationArea = All; }
                field("Plan_Currency"; Rec.Plan_Currency) { Caption = 'Currency code'; ApplicationArea = All; }
                field("Plan_ExchangeRate"; Rec.Plan_ExchangeRate) { Caption = 'Exchange rate'; ApplicationArea = All; }
                field("Plan_HCReq"; Rec.Plan_HCReq) { Caption = 'Head count requirement'; ApplicationArea = All; }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action("Create New Plan")
            {
                ApplicationArea = All;
                Image = NewDocument;
                trigger OnAction()
                begin
                    Message('Hello');
                    CollectPlanData();
                end;
            }
        }
    }

    local procedure CollectPlanData()
    var
        SalesLine: Record "Sales Line";
        PlanData: Record "SEI Planning Master Data";
    begin
        SalesLine.Init();
        PlanData.Init();

        SalesLine.SetFilter("No.", '07-2701-0374H');
        //SalesLine.SetRange("Planned Shipment Date", Today() - 30, Today());
        if SalesLine.Find('-') then begin
            repeat
                PlanData.Plan_ItemFG := SalesLine."No.";
                PlanData.Insert()
            until SalesLine.Next() = 0;
        end;
        //PlanData.Insert();



    end;
}

  • borics.krisztian Profile Picture
    borics.krisztian 17 on at
    RE: Indexing Error message

    Oh my God! It's working. I have checked many times the code, but I could not see this mistake. Thank you very much.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Indexing Error message

    Hi,

    This line is a problem

                   field("Plan_CreatedUser"; Rec.Plan_CreatedUser[40]) { Caption = 'Created by'; ApplicationArea = All; }

    try to make it like this

                   field("Plan_CreatedUser"; Rec.Plan_CreatedUser) { Caption = 'Created by'; ApplicationArea = All; }

  • borics.krisztian Profile Picture
    borics.krisztian 17 on at
    RE: Indexing Error message

    Already tried debug, but seems like this error came before onInsert trigger AL code execution because I could not see any data in debugger.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Indexing Error message

    Try to debug the problem.

  • borics.krisztian Profile Picture
    borics.krisztian 17 on at
    RE: Indexing Error message

    Hello,

    Thank you but situlation is same :(

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Indexing Error message

    Hi,

    Can you check your Field ID you mentioned on Table?

    its 005, 006, can you put like 50005, 50006 or whatever the range you have permission.

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!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans