web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Alert user when referenced table record on PO page has certain value

(3) ShareShare
ReportReport
Posted on by 184
I am trying to extend the Purchase Order page so that when the customer table record referenced in the /Sell-to Customer No./ field of the Shipping and Payment section has a Payment Terms value of Prepayment, the user would be notified/alerted. I have attempted the below, but aside from not working, it is also preventing the user from accessing existing POs from the list (The record is not open error).
 
Ideally, this would be a persistent notification on the page starting from when the user first selects the customer address, and a skippable message()/pop-up alert when the /Send Email/ button is pressed. From my limited understanding, an event subscriber would be used for this...? Just don’t know which/how to identify and use it here.
 
Appreciate any help!
 
    trigger OnOpenPage();    var        POProformaWarning: Notification;        POProformaWarningLbl: Label 'Shipping to PROFORMA customer; DO NOT send PO before payment confirmation!';        CustRecRefVar: RecordRef;        CustVar: Record Customer;        PaymentTermsCodeVar: Code[20];    begin        if Rec./Sell-to Customer No./ <> '' then begin            CustVar.Get(Rec./Sell-to Customer No./);            CustRecRefVar.SetTable(CustVar);            PaymentTermsCodeVar := CustVar./Payment Terms Code/;            if PaymentTermsCodeVar = 'PREPAYMENT' then begin                POProformaWarning.MESSAGE(POProformaWarningLbl);                POProformaWarning.SCOPE := NotificationScope::LocalScope;                POProformaWarning.Send();            end;        end;    end;}
I have the same question (0)
  • CU05061853-0 Profile Picture
    184 on at
    Alert user when referenced table record on PO page has certain value
    I tried another method shown below, inspired by this article by Yun Zhu; it is still not producing the desired outcome.
     
    Hope someone can point out where I'm going wrong?
     
     
        trigger OnOpenPage();
        var
            TableNumber: Integer;
            POProformaWarning: Notification;
            POProformaWarningLbl: Label 'Shipping to PROFORMA customer; DO NOT send PO before payment confirmation!';
            CustRecRef: RecordRef;
            CustFieldRef: FieldRef;
            PrepaymentCodeRef: Code[20];
        begin
            if (Rec."Sell-to Customer No." <> '') then begin
                TableNumber := Rec.Relation("Sell-to Customer No.");
                CustRecRef.Open(TableNumber);
                CustFieldRef := CustRecRef.Field(27);
                Evaluate(PrepaymentCodeRef, CustFieldRef.Value);
                if PrepaymentCodeRef = 'PREPAYMENT' then begin
                    POProformaWarning.MESSAGE(POProformaWarningLbl);
                    POProformaWarning.SCOPE := NotificationScope::LocalScope;
                    POProformaWarning.Send();
                end;
            end;
        end;
    }
     
    // same as above
     
        trigger OnInsertRecord(BelowxRec: Boolean): Boolean
        var
            TableNumber: Integer;
            POProformaWarning: Notification;
            POProformaWarningLbl: Label 'Shipping to PROFORMA customer; DO NOT send PO before payment confirmation!';
            CustRecRef: RecordRef;
            CustFieldRef: FieldRef;
            PrepaymentCodeRef: Code[20];
        begin
            if (Rec."Sell-to Customer No." <> '') then begin
                TableNumber := Rec.Relation("Sell-to Customer No.");
                CustRecRef.Open(TableNumber);
                CustFieldRef := CustRecRef.Field(27);
                Evaluate(PrepaymentCodeRef, CustFieldRef.Value);
                if PrepaymentCodeRef = 'PREPAYMENT' then begin
                    POProformaWarning.MESSAGE(POProformaWarningLbl);
                    POProformaWarning.SCOPE := NotificationScope::LocalScope;
                    POProformaWarning.Send();
                end;
            end;
        end;

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans