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":
Second when MODIFY() is called:
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