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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to mark a custom boolean when purchase order email sent to vendor

(2) ShareShare
ReportReport
Posted on by 286
Hi All,
 
I have a custom boolean field called "Sent to Vendor". What I want to achieve is to automatically set this field to true when a Purchase Order is emailed to the vendor.
This will serve as a visual indicator to show which POs have already been sent.
I have the same question (0)
  • Verified answer
    Ben Baxter Profile Picture
    6,620 Super User 2025 Season 2 on at
    You may not need that field.  When a document is emailed it is counted as Printed.  You can use the No. of Times Printed field.  Anything > 0 has been sent, I am making the assumption you are not printing the PO since it is being emailed.
     
    Best Regards,
    Ben Baxter
    Accent Software Inc
  • Netjacker2097 Profile Picture
    286 on at
    @Ben Baxter that is corrrect on your assumption, what your surgesting is a much simpler solution. I have manager to also work out the EmailSentSuccesfully boolean which give better control if it fails. Here are the code:
     
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Document-Mailing", 'OnAfterEmailSent', '', false, false)]
        procedure OnAfterEmailSent(
            ReportUsage: Integer;
            PostedDocNo: Code[20];
            EmailSentSuccesfully: Boolean;
            var TempEmailItem: Record "Email Item" temporary)
        var
            PurchHeader: Record "Purchase Header";
        begin
            if not EmailSentSuccesfully then
                exit;
     
            if PurchHeader.Get(PurchHeader."Document Type"::Order, PostedDocNo) then begin
                PurchHeader.Validate("Sent to Vendor", true);
                PurchHeader.Modify();
            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 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans