AL icon indicating copy to clipboard operation
AL copied to clipboard

Getting up a page fails if the underlying table for this page contains an "empty" record

Open netrri opened this issue 5 years ago • 1 comments

Please include the following with each issue:

1. Describe the bug I have built a simple standard card test page with a simple testtable bound to via SourceTable = testTable; -this page is brought up via a search in the bc user interface.
-To set the table to a specific record in order to show initiallly up there is some code in the onOpenPage trigger to set the TableView and update the page.

this runs ok but not if there is an "empty" record in the underlying table: image

this message will be shown and the page is closed: image

if I set the tableView to the page und run the page modal from code, it works fine.

2. To Reproduce Steps to reproduce the behavior:

fill the testtable with some records, one of it emtpy (see picture 1) I did it with the al-Go customer page extension (see below)

open the page via search: image

AL code snippet that demonstrates the issue or a link to a code repository the developers can easily pull down to recreate the issue locally

Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.

a simple table: table 50100 "testTable" { DataClassification = ToBeClassified;

fields
{
    field(1; "User Name"; Code[50])
    {
        DataClassification = EndUserIdentifiableInformation;
    }

    field(2; AbsoluteStartDate; Date)
    {
        DataClassification = CustomerContent;

    }

    field(3; AbsoluteEndDate; Date)
    {
        DataClassification = CustomerContent;

    }

}
keys
{
    key(PK; "User Name")
    {
        Clustered = true;
    }
}

a simple testpage, see the trigger OnOpenPage to initialize the "admin" record if no filter is set: page 50100 "TestPage" { PageType = Card; ApplicationArea = All; UsageCategory = Administration; SourceTable = testTable;

layout
{
    area(Content)
    {
        group(GroupName)
        {
            field(Name; Rec."User Name")
            {
                ApplicationArea = All;

            }
        }
    }
}

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

            trigger OnAction()
            begin

            end;
        }
    }
}

trigger OnOpenPage()
var
    _sourceTable: Record testTable;
begin
    if Rec.GetFilter("User Name") <> UserId() then begin
        _sourceTable.SetCurrentKey("User Name");
        _sourceTable.SetRange("User Name", UserId());
        CurrPage.SetTableView(_sourceTable);
        CurrPage.Update();
    end;
end;

pageextension 50100 CustomerListExt extends "Customer List" { actions { addlast("Display") { action(populateTestPage) { Caption = 'add some Test Records'; Enabled = true; Image = AddContacts; ApplicationArea = All; Promoted = true;

            trigger OnAction()
            var
                _testtable: Record testTable;
            begin
                _testtable."User Name" := UserId();
                _testtable.Insert(false);
                _testtable."User Name" := 'DummyUser1';
                _testtable.Insert(false);
                _testtable."User Name" := 'DummyUser2';
                _testtable.Insert(false);
            end;
        }

        action(addEmptyTestRecord)
        {
            Caption = 'add Empty Test Record';
            Enabled = true;
            Image = AddContacts;
            ApplicationArea = All;
            Promoted = true;

            trigger OnAction()
            var
                _testtable: Record testTable;
            begin
                _testtable.Insert(false);
            end;
        }

        action(removeEmptyTestRecord)
        {
            Caption = 'remove Empty Test Record';
            Enabled = true;
            Image = RemoveContacts;
            ApplicationArea = All;
            Promoted = true;

            trigger OnAction()
            var
                _testtable: Record testTable;
            begin
                _testtable.SetRange("User Name", '');
                if _testtable.FindFirst() then
                    _testtable.Delete(false);
            end;
        }
        action(showTestPage)
        {
            Caption = 'show Test page';
            Enabled = true;
            Image = RemoveContacts;
            ApplicationArea = All;
            Promoted = true;

            trigger OnAction()
            var
                _testtable: Record testTable;
                _testPage: Page TestPage;
            begin
                _testtable.SetRange("User Name", UserId);
                if _testtable.Get(UserId) then begin
                    _testPage.SetTableView(_testtable);
                    _testPage.RunModal();
                end;
            end;
        }
    }
}

}

3. Expected behavior the record "admin" should be adressed though an empty record may be in the table

if there is an other, better solution to initialize the start record (set the viewfilter, another trigger perhaps?) it would be nice to hear about it.

4. Actual behavior see picture above, the page closes.

5. Versions:

  • AL Language: v7.1.441584
  • Visual Studio Code: 1.55.2
  • Business Central: sandbox 18.0.23013.23795
  • List of Visual Studio Code extensions that you have installed:

Final Checklist

Please remember to do the following:

  • [x] Search the issue repository to ensure you are reporting a new issue

  • [] Reproduce the issue after disabling all extensions except the AL Language extension

  • [x] Simplify your code around the issue to better isolate the problem

netrri avatar Apr 20 '21 16:04 netrri

Hi! Please take a minute to read the guidelines for this repository https://github.com/microsoft/AL and our collection of frequently asked questions https://github.com/Microsoft/AL/wiki/frequently-Asked-Questions .

As this repository is only for issues related to the AL compiler in latest developer preview environment for Dynamics 365 Business Central. We suggest that you open a support case or file a bug in Collaborate, to ensure that all Business Central users benefit from your catch as soon as possible.

To open a support case, you can:

  • Open a support request to CSS through the PartnerSource portal
  • Contact your Service Account Manager (SAM) in your local subsidiary to understand what is included in your contract as of support incident and PAH (Partner Advisory Hours). Your SAM might also direct you "step by step" how to open a support request or how to get credentials, if this is the first time for you or your company

If you file the bug in Collaborate, remember to include steps to reproduce the issue, and the Business Central build number and country version you're using.

atoader avatar May 03 '21 12:05 atoader