Skip to main content

Notifications

Announcements

No record found.

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 130
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;}
  • CU05061853-0 Profile Picture
    CU05061853-0 130 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

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! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans