Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

How to Suspend Status Check for a Purchase Order from a new page.

(0) ShareShare
ReportReport
Posted on by 20
I have created a new page for fast updates for few fields of the header of a Purchase Order.
 
page 50151 /CE Purchase Order Simple/
{
    Caption = 'Purchase Order Simple';
    PageType = List;
    InsertAllowed = false;
    DeleteAllowed = false;
    SourceTable = /Purchase Header/;
    SourceTableView = WHERE(/Document Type/ = CONST(/Order/));
    ApplicationArea = All;
    UsageCategory = Lists;
 
    layout
    {
        area(content)
        {
            repeater(Control1)
            {
                field(/Order Number/; Rec./No./)
                {
                    ApplicationArea = All;
                    Caption = 'Order Number';
                    ToolTip = 'Purchase Order Number';
                    Editable = false;
                    Width = 7;
                }
                field(Status; Rec.Status)
                {
                    ApplicationArea = Suite;
                    ToolTip = 'Specifies whether the record is open, waiting to be approved, invoiced for prepayment, or released to the next stage of processing.';
                    StyleExpr = StatusStyleTxt;
                    Editable = false;
                }
                field(/Vendor/; Rec./Buy-from Vendor No./)
                {
                    ApplicationArea = All;
                    Caption = 'Vendor';
                    ToolTip = 'Specifies the number of the vendor who delivers the products.';
                    Editable = false;
                    Width = 6;
                }
                field(/Vendor Name/; Rec./Buy-from Vendor Name/)
                {
                    ApplicationArea = All;
                    Caption = 'Vendor Name';
                    ToolTip = 'Specifies the name of the vendor who delivers the products.';
                    Editable = false;
                    Width = 30;
                }
                field(/Location/; Rec./Location Code/)
                {
                    ApplicationArea = All;
                    Caption = 'Location';
                    ToolTip = 'Specifies a code for the location where you want the items to be placed when they are received.';
                    Editable = false;
                    Width = 4;
                }
                field(/Requested Receipt Date/; Rec./Requested Receipt Date/)
                {
                    ApplicationArea = All;
                    ToolTip = 'Specifies the date that you want the vendor to deliver to the ship-to address.';
                    Width = 12;
                }
                field(/Promised Receipt Date/; Rec./Promised Receipt Date/)
                {
                    ApplicationArea = All;
                    ToolTip = 'Specifies the date that the vendor has promised to deliver the order.';
                    Width = 12;
 
                    trigger OnValidate()
                    begin
                        Rec.SuspendStatusCheck(true);
                    end;
                }
            }
        }
    }
    trigger OnAfterGetRecord()
    begin
        StatusStyleTxt := Rec.GetStatusStyleText();
        Rec.SuspendStatusCheck(true);
    end;
 
    trigger OnOpenPage()
    begin
        BindSubscription(CePurchaseSuspendCheck);
    end;
 
    trigger OnClosePage()
    begin
        UnbindSubscription(CePurchaseSuspendCheck);
    end;
 
    var
        CePurchaseSuspendCheck: Codeunit /CE Purchase Suspend Check/;
        StatusStyleTxt: Text;
}
 
However when I change the Promise Receipt Date, I can't Spend the Open Status Check. I tried in the OnAfterGetRecord (doesn't work) and the OnValidate of the field (too late). I have also tried a BindSubscription in the OnOpenPage which works but if I open the Purchase Order List from the Tell Me/Search modal and select one PO from the list and go to edit the Promise Receipt Date on that Card page the Open Status Check is also suspended because my new page is still open in the stack of pages in the UI. I don't UnbindSubscription until my new page closes. I only want the Open Status Check to be suspended if the fields are changes from my new page only. It would be nice if my page could add the OnBeforeValidate trigger like page extensions object can do so I could Spend the Open Status Check from there.
 
Any help would be appreciated.
 
  • Jon A. Profile Picture
    Jon A. 20 on at
    How to Suspend Status Check for a Purchase Order from a new page.
    Thank you Yun Zhu for replying. However I think your solution would affect all Purchase Header "Promise Receipt Date" changes across the whole application.
    I'm just looking to suspend the check if the changes happen from my new page.
     
    If this worked it would be ideal
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,115 Super User 2024 Season 2 on at
    How to Suspend Status Check for a Purchase Order from a new page.
    Hi, I think trigger OnValidate() should be feasible. . . .
    Or you can change your mind, for example, put this control on the table.
     
    Hope this helps.
    Thanks.
    ZHU
  • Jon A. Profile Picture
    Jon A. 20 on at
    How to Suspend Status Check for a Purchase Order from a new page.
    Sorry, I can't get the code to format correctly. Here is also a screenshot:

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