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...
Suggested Answer

How to change table data after Email was sent successfully?

(0) ShareShare
ReportReport
Posted on by 397 User Group Leader

Hi, I am trying to extend a normal workflow with an EventSubscriper to change a specific Enum in the Sales Header of a Quote.

For that I created a codeunit - look at the code:

codeunit 50144 StatusInternCodeunit


{
    Permissions = tabledata "Sales Header" = RIMD;
    Access = Public;
    trigger OnRun()
    begin

    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Document-Mailing", 'OnAfterEmailSentSuccesfully', '', false, false)]

    local procedure OnAfterSendMailAddVersendet()
    var
        SalesHeader: Record "Sales Header";
        StatusEnum: Enum StatusSalesQuoteEnum;
        SalesEnum: Enum "Sales Document Type";
    begin
        if (SalesHeader."Document Type"::Quote = SalesEnum::Quote) then begin
            SalesHeader.Validate("Status Intern", StatusEnum::Versendet);
            SalesHeader.MODIFY;
        end;
    end;

    var

}


//Missing the correct quote...

After the codeunit runs nothing changed so I have issues with getting the data/enum changed...

First, when calling "Send by Mail":

pastedimage1645802518597v2.png

Second when MODIFY() is called:

pastedimage1645802584077v3.png

pastedimage1645802607175v4.png

English: 

'Sales header' does not exist. Identifying fields and values: Document Type='Offer',No.=''

I think, it has issues with getting the right quote to change the right value, but how can I get the right/actual quote to change the table data?

Thank you guys, I am currently learning AL Programming and try to get better everyday.

Tom

I have the same question (0)
  • Suggested answer
    Andy Sather Profile Picture
    on at

    Hello  - We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    I will open this up to the community in case they have something to add.

  • T_Mauser Profile Picture
    397 User Group Leader on at

    Hmm I cannot find the group on yammer or the link isn't working (Error 404)

    Would be great if you can share the information!

    Thank you.

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,151

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,443 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans