Skip to main content

Notifications

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

Cannot add new field to existing page

Posted on by 5

Hi all,

I am currently trying to add an extra field to the "Item" table - displaying that field on the "Item Card" page via an AL extension.  If I just add the field to the table the extension deploys to my sandbox successfully.  The code I'm using is virtually a direct copy from the documentation at: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-page-ext-object

When I attempt to deploy (Ctrl F5) the extension it gives me the error "error AL0118: The name 'MyField' does not exist in the current context." - which is referring to the "field" entry in the pageextension - i.e. It cannot find the field I created in my table extension.

If I change the "expression" portion of that statement to a literal value (e.g. 12345) then the field displays as expected (read only with the literal value in it).  What am I missing (seems like it shouldn't be this hard to get it to work).  I've even tried copying the "ShoeSize" code from the above link and it too doesn't exist.

Using latest AL extension in VSCode.  Cloud based BC (all up to date).

Not sure if there's a specific Dev forum I should be posting this in - please redirect me if there is.

Thanks,

Scott S.

tableextension 50100 ItemTableExtension extends Item
{
    fields
    {
        field(50101; MyField; Text[50])
        {
            Caption = 'My Field';
        }
    }

}

pageextension 50102 ItemCardExtension extends "Item Card"
{
    layout
    {
        // Add changes to page layout here
        addlast(Item)
        {
            field("My Field"; MyField)
            {
                ApplicationArea = All;
            }

        }
    }

}

Categories:
  • ssouthurst Profile Picture
    ssouthurst 5 on at
    RE: Cannot add new field to existing page

    That was exactly it!  Thanks!

    I did look at the "NoImplicitWith" page but didn't see anything that made me think it applied to my issue.

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 73,378 Super User 2024 Season 2 on at
    RE: Cannot add new field to existing page

    Hi, if your Sandbox is BC21, I think you just missed "Rec.".

    For example,

    pastedimage1674776682890v1.png

    More details: Business Central 2022 wave 2 (BC21) new features: Enable NoImplicitWith feature by default (New feature setting in app.json file)

    https://yzhums.com/29196/

    Hope this helps.

    Thanks.

    ZHU

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!

Community AMA December 12th

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,064 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans