Skip to main content

Notifications

Announcements

No record found.

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

AL-developed page opening "New Document" card in Read-Only

(0) ShareShare
ReportReport
Posted on by 67

I am starting to learn development in BC, and trying to follow along with the tutorial below...

Exercise - Create a List page - Training | Microsoft Learn

I am able to create the card and list pages; however, the "New" button takes me to a card with read-only files. How do I get this to open in edit-mode?

I have tried setting "Editable = true;" at the group level, and field level of the card page

pastedimage1667507526774v1.png

I'm not sure if this is a permissions issue, or if I configuyred the code incorrectly...

Here is code for my Card page...

page 50100 "CRONUS Course Card"
{
    PageType = Card;
    UsageCategory = None;
    SourceTable = "CRONUS Course";

    layout
    {
        area(Content)
        {
            group(General)
            {
                Caption = 'General';

                field(Code; 'CRONUS Course New Test')
                {
                    ApplicationArea = All;

                }
                field(Name; 'CRONUS Course')
                {
                    ApplicationArea = All;

                }
                field(Description; 'CRONUS Course')
                {
                    ApplicationArea = All;

                }
            }
            group(Details)
            {
                Caption = 'Details';

                field(Duration; '')
                {
                    ApplicationArea = All;

                }
                field(Price; 'CRONUS Course')
                {
                    ApplicationArea = All;

                }
                field(Type; 'CRONUS Course')
                {
                    ApplicationArea = All;

                }
                field(Active; 'CRONUS Course')
                {
                    ApplicationArea = All;

                }
                field("Instructor Code"; 'CRONUS Course')
                {
                    ApplicationArea = All;

                }
                field("Instructor Name"; 'CRONUS Course')
                {
                    ApplicationArea = All;

                }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action(Resource)
            {
                Caption = 'Resource';
                ToolTip = 'Open the Resource Card';
                RunObject = page "Resource Card";
                RunPageLink = "No." = field("Instructor Code");
                Image = Relationship;
                Promoted = true;
                PromotedCategory = Process;
                ApplicationArea = All;
                trigger OnAction()
                begin

                end;
            }
        }
    }

}
Here's the code for my list page...
page 50101 "CRONUS Course List"
{
    PageType = List;
    ApplicationArea = All;
    UsageCategory = Lists;
    SourceTable = "CRONUS Course";
    Caption = 'Course List';
    Editable = false;
    CardPageId = "CRONUS Course Card";

    layout
    {
        area(Content)
        {
            repeater(General)
            {
                field(code; 'CRONUS Course')
                {

                }
                field(Name; 'CRONUS Course')
                {

                }
                field(Description; 'CRONUS Course')
                {

                }
                field(Price; 'CRONUS Course')
                {

                }
                field("Instructor Name"; 'CRONUS Course')
                {

                }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action(ActionName)
            {
                ApplicationArea = All;

                trigger OnAction()
                begin

                end;
            }
        }
    }

    var
        myInt: Integer;
}
Here's the code for my table
table 50100 "CRONUS Course"
{
    DataClassification = CustomerContent;
    Caption = 'Course';
    LookupPageId = "CRONUS Course List";
    DrillDownPageId = "CRONUS Course List";

    fields
    {
        field(10; "Code"; Code[10])
        {
            DataClassification = CustomerContent;
            Caption = 'Code';
        }
        field(20; "Name"; Text[30])
        {
            DataClassification = CustomerContent;
            Caption = 'Name';
        }
        field(30; "Description"; Text[50])
        {
            DataClassification = CustomerContent;
            Caption = 'Description';
        }
        field(40; "Type"; Option)
        {
            DataClassification = CustomerContent;
            Caption = 'Type';
            OptionMembers = "Instructor Led","e-Learning","Remote Training";
            OptionCaption = 'Instructor Led, e-Learning, Remote Training';
        }
        field(50; "Duration"; Decimal)
        {
            DataClassification = CustomerContent;
            Caption = 'Duration';
        }
        field(60; "Price"; Decimal)
        {
            DataClassification = CustomerContent;
            Caption = 'Price';
        }
        field(70; "Active"; Boolean)
        {
            DataClassification = CustomerContent;
            Caption = 'Active';
        }
        field(80; "Difficulty"; Integer)
        {
            DataClassification = CustomerContent;
            Caption = 'Difficulty';
        }
        field(90; "Passing Rate"; Integer)
        {
            DataClassification = CustomerContent;
            Caption = 'Passing Rate';
        }
        field(100; "Instructor Code"; Code[20])
        {
            DataClassification = CustomerContent;
            Caption = 'Instructor Code';
            TableRelation = "Resource" where(Type = const(Person));
        }
    }

    keys
    {
        key(PK; Code)
        {
            Clustered = true;
        }
        key(Key1; "Instructor Code")
        {
        }
        key(Key2; Type)
        {
        }
    }


}
Here's the code for my JSON launch file...
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Microsoft cloud sandbox",
            "request": "launch",
            "type": "al",
            "environmentType": "Sandbox",
            "environmentName": "sandbox",
            "startupObjectId": 50101,
            "startupObjectType": "Page",
            "breakOnError": "All",
            "launchBrowser": true,
            "enableLongRunningSqlStatements": true,
            "enableSqlInformationDebugger": true
        }
    ]
}
  • ERPlatanos Profile Picture
    ERPlatanos 67 on at
    RE: AL-developed page opening "New Document" card in Read-Only

    Roberto,

    This solved my problem.

    Thanks for your help.

  • Verified answer
    Robyn2018 Profile Picture
    Robyn2018 Most Valuable Professional on at
    RE: AL-developed page opening "New Document" card in Read-Only

    Hi,

    You have a problem in your card page.  

    The field definitions are not correct.  You must put field (nameToIdentifyTheControl;rec.Field)

    The nameToIdentifytheControl can be as you prefer, but the second part is always a field in your table or a variable.  If you put a literal like 'CRONUS Course', you are not showing any field, only literals, so for what do you need a new record.  For this reason the + button is disabled.

    I hope help you to work with Business Central

    page 50100 "CRONUS Course Card"
    {
        PageType = Card;
        UsageCategory = None;
        SourceTable = "CRONUS Course";

        layout
        {
            area(Content)
            {
                group(General)
                {
                    Caption = 'General';

                    field(code; rec.code)
                    {
                        ApplicationArea = All;

                    }
                    field(name; rec.Name)
                    {
                        ApplicationArea = All;

                    }
                    field(Description; Rec.Description)
                    {
                        ApplicationArea = All;

                    }
                }
                group(Details)
                {
                    Caption = 'Details';

                    field(Duration; Rec.Duration)
                    {
                        ApplicationArea = All;

                    }
                    field(Price; Rec.Price)
                    {
                        ApplicationArea = All;

                    }
                    field(Type; Rec.Type)
                    {
                        ApplicationArea = All;

                    }
                    field(Active; Rec.Active)
                    {
                        ApplicationArea = All;

                    }
                    field("Instructor Code"; Rec."Instructor Code")
                    {
                        ApplicationArea = All;

                    }

                }
            }
        }

        actions
        {
            area(Processing)
            {
                action(Resource)
                {
                    Caption = 'Resource';
                    ToolTip = 'Open the Resource Card';
                    RunObject = page "Resource Card";
                    RunPageLink = "No." = field("Instructor Code");
                    Image = Relationship;
                    Promoted = true;
                    PromotedCategory = Process;
                    ApplicationArea = All;
                    trigger OnAction()
                    begin

                    end;
                }
            }
        }

    }

    pastedimage1667512848869v1.png

    Don't forget to help the community by verifying the answer or at least like the suggestion if it did help in any way. It will let others know that the topic has verified answer and was beneficial to you.

    Roberto Corella

    Business Central developer

    blog: https://blog.msdyn365bc.es
    youtube channel: www.youtube.com/.../UCeIS0DjQXp4R-aWY20PSVyg
    Linkedin: www.linkedin.com/.../
    Twitter: https://twitter.com/rccorella

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans