ENUM requests
Hi,
can you please convert the following into ENUM:
- Table 77 "Report Selections" - field "Usage"
- Table 179 "Reversal Entry" - field "Entry Type"
Probably superfluously, but just something that should be taken into consideration regarding item 1: Table 9657 "Custom Report Selection" - field 3 "Usage" seems to use the same Option string as T77 (and therefore should probably use the same enum).
Hi,
Thank you for your request. We have identified several places where we are going to add events. See below. Please let us know if something is missing to support your scenarios.
COD2114: CreateHTMLTextFromReportSelections
CASE Usage OF
Usage::"S.Invoice":
FillSalesInvoiceHTML(RecordVariant,HTMLText,MailTo,MailText);
Usage::"S.Invoice Draft":
FillSalesDraftInvoiceHTML(RecordVariant,HTMLText,MailTo,MailText);
Usage::"S.Quote":
FillSalesEstimateHTML(RecordVariant,HTMLText,MailTo,MailText);
ELSE
OnCreateHTMLTextFromReportSelections(ReportSelections,RecordVariant,MailTo,MailText,HTMLText);
[Integration]
LOCAL PROCEDURE OnCreateHTMLTextFromReportSelections@29(ReportSelections@1002 : Record 77;RecordVariant@1000 : Variant;MailTo@1001 : Text;MailText@1003 : Text; VAR HTMLText@1004: Text);
BEGIN
END;
COD2151: InitializeDocumentSpecificVariables
IF SalesInvoiceHeader.GET(DocumentNo) THEN BEGIN
SalesInvoiceHeader.SETRECFILTER;
DocumentRecordVariant := SalesInvoiceHeader;
CustomerNo := SalesInvoiceHeader."Bill-to Customer No.";
ReportUsage := ReportSelections.Usage::"S.Invoice";
DocumentType := DocumentType::Invoice;
OnInitializeDocumentSpecificVariablesWithSalesInvHeader(SalesInvoiceHeader, ReportUsage);
EXIT(TRUE);
END;
[...]
IF SalesHeader.IsTest THEN
IsTestInvoice := TRUE;
OnInitializeDocumentSpecificVariablesWithSalesHeader(SalesHeader, ReportUsage);
EXIT(TRUE);
[Integration]
LOCAL PROCEDURE OnInitializeDocumentSpecificVariablesWithSalesInvHeader@5(SalesInvoiceHeader@1001 : Record 112;VAR ReportUsage@1000 : Integer);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnInitializeDocumentSpecificVariablesWithSalesHeader@8(SalesHeader@1001 : Record 36;VAR ReportUsage@1000 : Integer);
BEGIN
END;
COD229:
In procedures: GetSalesDocTypeUsage GetPurchDocTypeUsage GetServContractTypeUsage GetServHeaderDocTypeUsage GetAsmHeaderDocTypeUsage GetSalesOrderUsage GetSalesArchDocTypeUsage GetPurchArchDocTypeUsage
Events added in the ELSE of each switch CASE:
[Integration]
LOCAL PROCEDURE OnGetSalesDocTypeUsage@51(SalesHeader@1000 : Record 36;VAR ReportUsageResult@1002 : Option;VAR Handled@1001 : Boolean);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnGetPurchDocTypeUsage@52(PurchHeader@1000 : Record 38;VAR ReportUsageResult@1002 : Option;VAR Handled@1001 : Boolean);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnGetServContractTypeUsage@53(ServiceContractHeader@1000 : Record 5965;VAR ReportUsageResult@1002 : Option;VAR Handled@1001 : Boolean);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnGetServHeaderDocTypeUsage@54(ServiceHeader@1000 : Record 5900;VAR ReportUsageResult@1002 : Option;VAR Handled@1001 : Boolean);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnGetAsmHeaderDocTypeUsage@55(AsmHeader@1000 : Record 900;VAR ReportUsageResult@1002 : Option;VAR Handled@1001 : Boolean);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnGetSalesOrderUsage@56(Usage@1001 : 'Order Confirmation,Work Order,Pick Instruction';VAR ReportUsageResult@1002 : Option;VAR Handled@1003 : Boolean);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnGetSalesArchDocTypeUsage@57(SalesHeaderArchive@1000 : Record 5107;VAR ReportUsageResult@1002 : Option;VAR Handled@1001 : Boolean);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnGetPurchArchDocTypeUsage@58(PurchHeaderArchive@1000 : Record 5109;VAR ReportUsageResult@1002 : Option;VAR Handled@1001 : Boolean);
BEGIN
END;
COD260: GetAttachmentFileName Added in the first line:
OnBeforeGetAttachmentFileName(AttachmentFileName,PostedDocNo,EmailDocumentName,ReportUsage);
[Integration]
LOCAL PROCEDURE OnBeforeGetAttachmentFileName@14(VAR AttachmentFileName@1000 : Text[250];PostedDocNo@1001 : Code[20];EmailDocumentName@1004 : Text[250];ReportUsage@1002 : Option);
BEGIN
END;
COD452: SendXmlEmailAttachment
IF DocumentSendingProfile.Usage = DocumentSendingProfile.Usage::"Job Quote" THEN
ReportUsage := ReportSelections.Usage::JQ
ELSE
OnSendXmlEmailAttachment(DocumentVariant,DocumentFormat,ServerEmailBodyFilePath,SendToEmailAddress,ReportUsage);
SendXmlEmailAttachmentVendor
IF DocumentSendingProfile.Usage = DocumentSendingProfile.Usage::"Job Quote" THEN
ReportUsage := ReportSelections.Usage::JQ
ELSE
OnSendXmlEmailAttachmentVendor(DocumentVariant,DocumentFormat,ServerEmailBodyFilePath,SendToEmailAddress,ReportUsage);
[Integration]
LOCAL PROCEDURE OnSendXmlEmailAttachment@18(DocumentVariant@1000 : Variant;DocumentFormat@1008 : Code[20];ServerEmailBodyFilePath@1004 : Text[250];SendToEmailAddress@1009 : Text[250];VAR ReportUsage@1010 : Option);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnSendXmlEmailAttachmentVendor@19(DocumentVariant@1003 : Variant;DocumentFormat@1002 : Code[20];ServerEmailBodyFilePath@1001 : Text[250];SendToEmailAddress@1000 : Text[250];VAR ReportUsage@1010 : Option);
BEGIN
END;
PAG2150: GetEmailBody
OnGetEmailBodySetReportUsage(DocumentHeaderRecordVariant,ReportUsage);
IF ReportSelections.GetEmailBodyCustomText(TempEmailItem."Body File Path",ReportUsage,DocumentHeaderRecordVariant,
CustomerNo,SendTo,TempEmailItem.GetBodyText)
THEN
TempEmailItem.MODIFY;
COMMIT;
END;
[Integration]
LOCAL PROCEDURE OnGetEmailBodySetReportUsage@8(DocumentHeaderRecordVariant@1000 : Variant;VAR ReportUsage@1001 : Option);
BEGIN
END;
TAB2170: ReportUsageToDocumentType Added
ELSE
OnReportUsageToDocumentType(DocumentType,ReportUsage);
[Integration]
LOCAL PROCEDURE OnReportUsageToDocumentType@11(VAR DocumentType@1000 : Option;ReportUsage@1001 : Option);
BEGIN
END;
TAB38: GetReportSelectionsUsageFromDocumentType At the end, added:
OnAfterGetReportSelectionsUsageFromDocumentType(Rec,ReportSelectionsUsage,DocTxt);
[Integration]
LOCAL PROCEDURE OnAfterGetReportSelectionsUsageFromDocumentType@133(PurchaseHeader@1000 : Record 38;VAR ReportUsage@1001 : Option;VAR DocText@1002 : Text[150]);
BEGIN
END;
TAB60: GetMultipleDocumentsName Added
ELSE
OnGetMultipleDocumentsName(DocName,ReportUsage);
[Integration]
LOCAL PROCEDURE OnGetMultipleDocumentsName@44(VAR DocName@1002 : Text[150];ReportUsage@1000 : Option);
BEGIN
END;
TAB77: SendEmailDirectly
IF ReportUsage = Usage::JQ THEN BEGIN
Usage := ReportUsage;
CustomReportSelection.SETFILTER(Usage,GETFILTER(Usage));
IF CustomReportSelection.FINDFIRST THEN
IF CustomReportSelection."Send To Email" <> '' THEN
DefaultEmailAddress := CustomReportSelection."Send To Email";
END ELSE
OnSendEmailDirectly(ReportUsage,Usage,RecordVariant,DocNo,DocName,FoundBody,FoundAttachment,
ServerEmailBodyFilePath,DefaultEmailAddress,ShowDialog,TempAttachReportSelections,CustomReportSelection);
GetPurchaseOrderEmailAddress At the beginning:
OnBeforeGetPurchaseOrderEmailAddress(BuyFromVendorNo,RecVar,ReportUsage,EmailAddress,Handled);
IF Handled THEN
EXIT(EmailAddress);
ReportUsageToDocumentType: Added ELSE to the switch case.
[Integration]
LOCAL PROCEDURE OnReportUsageToDocumentType@86(VAR DocumentType@1001 : Option;ReportUsage@1000 : Option; VAR Handled@1002: Boolean);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnBeforeGetPurchaseOrderEmailAddress@87(BuyFromVendorNo@1000 : Code[20];RecVar@1001 : Variant;ReportUsage@1002 : Option;VAR EmailAddress@1003: Text[250];VAR Handled@1004: Boolean);
BEGIN
END;
[Integration]
LOCAL PROCEDURE OnSendEmailDirectly@90(ReportUsage@1005 : Option;VAR UsageVar@1011 : Option;RecordVariant@1004 : Variant;DocNo@1003 : Code[20];DocName@1002 : Text[150];FoundBody@1006 : Boolean;FoundAttachment@1007 : Boolean;ServerEmailBodyFilePath@1008 : Text[250];VAR DefaultEmailAddress@1010 : Text[250];ShowDialog@1009 : Boolean;VAR TempAttachReportSelections@1020 : TEMPORARY Record 77;VAR CustomReportSelection@1000 : Record 9657);
BEGIN
END;
About the Usage field of Custom Report Selection, this should be asked in a separate Enum request. But some investigations showed that in the Russian localization, the two usage fields differ:
RU TAB9657 S.Quote,S.Order,S.Invoice,S.Cr.Memo,S.Test,P.Quote,P.Order,P.Invoice,P.Cr.Memo,P.Receipt,P.Ret.Shpt.,P.Test,B.Stmt,B.Recon.Test,B.Check,Reminder,Fin.Charge,Rem.Test,F.C.Test,Prod.Order,S.Blanket,P.Blanket,M1,M2,M3,M4,Inv1,Inv2,Inv3,SM.Quote,SM.Order,SM.Invoice,SM.Credit Memo,SM.Contract Quote,SM.Contract,SM.Test,S.Return,P.Return,S.Shipment,S.Ret.Rcpt.,S.Work Order,Invt.Period Test,SM.Shipment,S.Test Prepmt.,P.Test Prepmt.,S.Arch.Quote,S.Arch.Order,P.Arch.Quote,P.Arch.Order,S.Arch.Return,P.Arch.Return,USI,USCM,UCI,UCO,CB,CI,CO,UAS,AS,UIS,UIR,,IS,IR,,UFAW,UFAR,UFAM,FAW,FAR,FAM,FAJ,FARJ,PIJ,UPI,IRJ,UPCM,Asm.Order,P.Asm.Order,DT,S.Order Pick Instruction,UCSD,CSI,CSCM,C.Statement,V.Remittance,JQ,S.Invoice Draft,Pro Forma S. Invoice,P.Arch.Blanket,S.Arch.Blanket
RU TAB77 S.Quote,S.Order,S.Invoice,S.Cr.Memo,S.Test,P.Quote,P.Order,P.Invoice,P.Cr.Memo,P.Receipt,P.Ret.Shpt.,P.Test,B.Stmt,B.Recon.Test,B.Check,Reminder,Fin.Charge,Rem.Test,F.C.Test,Prod.Order,S.Blanket,P.Blanket,M1,M2,M3,M4,Inv1,Inv2,Inv3,SM.Quote,SM.Order,SM.Invoice,SM.Credit Memo,SM.Contract Quote,SM.Contract,SM.Test,S.Return,P.Return,S.Shipment,S.Ret.Rcpt.,S.Work Order,Invt.Period Test,SM.Shipment,S.Test Prepmt.,P.Test Prepmt.,S.Arch.Quote,S.Arch.Order,P.Arch.Quote,P.Arch.Order,S.Arch.Return,P.Arch.Return,Asm.Order,P.Asm.Order,S.Order Pick Instruction,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,C.Statement,V.Remittance,JQ,S.Invoice Draft,Pro Forma S. Invoice,S.Arch.Blanket,P.Arch.Blanket,Phys.Invt.Order Test,Phys.Invt.Order,P.Phys.Invt.Order,Phys.Invt.Rec.,P.Phys.Invt.Rec.,USI,USCM,UCI,UCO,CB,CI,CO,UAS,AS,UIS,UIR,,IS,IR,,UFAW,UFAR,UFAM,FAW,FAR,FAM,FAJ,FARJ,PIJ,UPI,IRJ,UPCM,DT,SOPI,UCSD,CSI,CSCM
Hi, thank you. This covers what I need, so I will mark this closed.
I cannot find any of these new events listed above in the Spring 2019 release? When will they be shipped? Could we have any example of how to use those event to extend Usage-option with more choice for "Report Selections".
Hi,
Indeed the changes didn't make it for the Spring 2019 release as we discovered unexpected challenges that require more work, because of the way Options are handled in the BaseApp code (see GetNumberOfOptions in Codeunit 10 for instance). The way to fix it requires some additional features from the platform. Hopefully this will be released in the Fall release, but that depends on the prioritization of our total backlog.
To be clear, the events are not used to extend the usage option. For this, you can refer to https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-extensible-enums and in particular the use of "enumextension". The events mentionned above are here to help you support all cases where the option is used and where you may want to do the appropriate handling for your new option value.
Most of the events follow the same pattern: subscribe to them and do the appropriate handling for your new extended option value. Here is some kind of pseudocode example:
[Subscriber to one of the events]
LOCAL PROCEDURE OnSomeEvent(VAR SomeVarParamResult : SomeType;SomeOtherUsefulParams: SomeTypes;ReportUsage : Option;VAR Handled: Boolean);
BEGIN
IF ReportUsage = ReportUsage::MyNewOptionValue THEN BEGIN
SomeVarParamResult := SomeSpecificHandlingForMyNewOptionValue(SomeOtherUsefulParams);
Handled := TRUE; // Handled pattern
END;
END;
@DavidBastide Why is this issue 'Closed' when no solution has been delivered? Waiting untill AFTER the next fall release will delay us even more in moving our code to AL before fall...
We're especially awaiting for the OnBeforeGetPurchDocTypeUsage event in COD229 since we'd like to print purchase invoices / creditmemo via the report selections (~ vendor self-billing in DK)
LOCAL GetPurchDocTypeUsage(PurchHeader : Record "Purchase Header") : Integer
CASE PurchHeader."Document Type" OF
PurchHeader."Document Type"::Quote:
EXIT(ReportSelections.Usage::"P.Quote");
PurchHeader."Document Type"::"Blanket Order":
EXIT(ReportSelections.Usage::"P.Blanket");
PurchHeader."Document Type"::Order:
EXIT(ReportSelections.Usage::"P.Order");
PurchHeader."Document Type"::"Return Order":
EXIT(ReportSelections.Usage::"P.Return");
// NVT-BEGIN: Event requested
PurchHeader."Document Type"::Invoice:
EXIT(1000); // Use fictive number in order to avoid errors
PurchHeader."Document Type"::"Credit Memo":
EXIT(1001); // Use fictive number in order to avoid errors
// NVT-END
ELSE
ERROR('');
END;
Sorry about the confusion. The issue shouldn't yet have been closed. I seems it was closed by a user and we failed to catch that. Unfortunately we had to abort check-in due to the aforementioned issues. We are working hard to pave the way for our first option to enum conversion, but it has proven itself more tricky (and much more time consuming) than initially anticipated. We're hoping to have a resolution soon, after which we will begin to process the many enum conversion requests registered here on GitHub.
Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. We will update this issue with information about availability.