Skip to main content

Notifications

Announcements

No record found.

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

How can the due date field be filtered like posting date?

(0) ShareShare
ReportReport
Posted on by 40

Hi, everyone

This is the field I added to the AL code

pastedimage1680849736889v1.png

But there is no way to use filtering.

How can the due date field be filtered like posting date?

Thank you!

  • Gianfranco C. Profile Picture
    Gianfranco C. 370 on at
    RE: How can the due date field be filtered like posting date?

    do not call the updateDueDate() function on the page. if you set a caclformula, there is no point in using a function to retrieve the value.

  • Hsuan Hung Profile Picture
    Hsuan Hung 40 on at
    RE: How can the due date field be filtered like posting date?
    table 50103 "Warehouse Shipment Header1"
    {
        Caption = 'Warehouse Shipment Header1';
        DataCaptionFields = "No.";
        LookupPageID = "Warehouse Shipment List";
        fields
        {
            field(1; "No."; Code[20])
            {
                Caption = 'No.';
            }
            field(2; "Due Date"; Date)
            {
                Caption = 'Due Date';
                FieldClass = FlowField;
                CalcFormula = lookup("Warehouse Shipment Line"."Due Date" where("No." = field("No.")));

            }
        }


    }
    pageextension 50205 Warehouse_Shipment_List extends "Warehouse Shipment List"
    {
        layout
        {
            addafter("Location Code")
            {
                field("Due Date"; REC."Due Date")
                {
                    ApplicationArea = All;
                }
            }

        }
        trigger OnAfterGetRecord()
        begin
            updateDueDate()
        end;

        trigger OnOpenPage()
        begin
            updateDueDate()
        end;

        local procedure updateDueDate()
        var
            WarehouseShipmentLine: Record "Warehouse Shipment Line";

        begin
            Clear(rec."Due Date");
            WarehouseShipmentLine.Reset();
            WarehouseShipmentLine.SetRange("No.", REC."No.");
            if WarehouseShipmentLine.FindSet() then
                rec."Due Date" := WarehouseShipmentLine."Due Date";
        END;

        var
            "Due Date": Date;
            Pos: Integer;
    }
  • RE: How can the due date field be filtered like posting date?

    Hi Hsuan,

    I think you should remove table relation from this field.

  • Gianfranco C. Profile Picture
    Gianfranco C. 370 on at
    RE: How can the due date field be filtered like posting date?

    can you post all the code for the extended and new objects?  

  • Hsuan Hung Profile Picture
    Hsuan Hung 40 on at
    RE: How can the due date field be filtered like posting date?

    I published from VS Code,and set the property "schemaUpdateMode": "ForceSync"

    But still can't filter due date field.

  • Suggested answer
    Gianfranco C. Profile Picture
    Gianfranco C. 370 on at
    RE: How can the due date field be filtered like posting date?

    you went from extending the standard table to creating a new one?

    If you are in a sandbox environment and have not yet published any of these changes in production, you can solve this by simply forcing the installation in this way:

    1) if you publish from VSCode: in the file launch.json set the property "schemaUpdateMode": "ForceSync"

    2) if you publish to PTE directly in the environment, on the app upload page, set "Schema Sync Mode" to Force

  • Hsuan Hung Profile Picture
    Hsuan Hung 40 on at
    RE: How can the due date field be filtered like posting date?

    unable to publish

    Reason: Table Warehouse Shipment Header1 :: The field 'Due Date' cannot be located. Removing fields is not allowed.

    table 50103 "Warehouse Shipment Header1"

    {

       Caption = 'Warehouse Shipment Header1';

       DataCaptionFields = "No.";

       LookupPageID = "Warehouse Shipment List";

       fields

       {

           field(1; "No."; Code[20])

           {

               Caption = 'No.';

           }

           field(2; "Due Date"; Date)

           {

               Caption = 'Due Date';

               FieldClass = FlowField;

               CalcFormula = lookup("Warehouse Shipment Line"."Due Date" where("No." = field("No.")));

           }

       }

    }

  • Suggested answer
    Gianfranco C. Profile Picture
    Gianfranco C. 370 on at
    RE: How can the due date field be filtered like posting date?

    the 'Due Date' field is header, so it shows the data stored in the header:
    in your case you added it later, and there is no logic (no code) that values it (the code you use does not store anything, and would be executed each time the page is opened).

    Moreover, your code values the field according to the first record of the rows linked to each header.
    are you sure that the two dates of the rows in each document are the same?

    if you are sure, you could set the field in the header like this:

    pastedimage1680855795448v1.png

    Don't forget to help the community by Verifying the answer and Like it if your question has been answered. It will let others know that the topic has verified answer.

    Thanks & Regards,Gian

  • Hsuan Hung Profile Picture
    Hsuan Hung 40 on at
    RE: How can the due date field be filtered like posting date?

    pageextension 50205 Warehouse_Shipment_List extends "Warehouse Shipment List"

    {

       layout

       {

           addafter("Location Code")

           {

               field("Due Date"; REC."Due Date")

               {

                   ApplicationArea = All;

                   Editable = false;

               }

           }

       }

       /*trigger OnAfterGetRecord()

       begin

           updateDueDate()

       end;*/

       trigger OnOpenPage()

       begin

           updateDueDate()

       end;

       local procedure updateDueDate()

       var

           WarehouseShipmentLine: Record "Warehouse Shipment Line";

       begin

           Clear(rec."Due Date");

           WarehouseShipmentLine.Reset();

           WarehouseShipmentLine.SetRange("No.", REC."No.");

           if WarehouseShipmentLine.FindSet() then

               rec."Due Date" := WarehouseShipmentLine."Due Date";

       END;

    }

    Is this correct? Thank you!

  • Hsuan Hung Profile Picture
    Hsuan Hung 40 on at
    RE: How can the due date field be filtered like posting date?

    Our actual delivery date is the due date field, so I want to filter out the WS to be shipped on that day.

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