Describe the issue
When manually creating an E-Document from a posted document page via action Related - E-Document - Create, if the system does not create an E-Document it still shows the message 'The e-document has been created.'.
There are cases when the e-document cannot be created due to a configuration error (for example, when a Document Sending Profile is not set up), in which case the system displays the corresponding error message.
However, there is a case when the system fails to create the e-document because the document type is not supported by the E-Document Service (which is configured in E-Document Service Supported Source Document Types), and it does not return an error, but rather just exists with false.
namespace Microsoft.eServices.EDocument;
codeunit 6102 "E-Doc. Export"
{
procedure CreateEDocument(var EDocument: Record "E-Document"; var DocumentHeader: RecordRef; var EDocumentService: Record "E-Document Service"; EDocumentType: Enum "E-Document Type"): Boolean
var
EDocumentLog: Codeunit "E-Document Log";
SupportedServices: List of [Code[20]];
Code: Code[20];
begin
EDocument.SetRange("Document Record ID", DocumentHeader.RecordId);
if not EDocument.IsEmpty() then
exit(false);
if EDocumentService.FindSet() then
repeat
if IsDocumentSupported(EDocumentService, DocumentHeader, EDocumentType) then
SupportedServices.Add(EDocumentService.Code);
until EDocumentService.Next() = 0;
if SupportedServices.Count() = 0 then
exit(false);
...
end;
}
Expected behavior
The code in the action to manually create the E-Document from a posted document should check if an e-document has actually been created, and show a message 'Could not create the E-Document' if it was not and there is no explicit exception.
Steps to reproduce
- Set up an E-Document Service. Do not specify Sales Invoice on the Configure documents to export page.
- Configure corresponding E-Document Workfow and Document Sending Profile.
- Open a Posted Sales Invoice card page on a document for which an E-Document has not been created earlier.
- Click Related - E-Document - Create
- Verify that the system displays the message 'The e-document has been created.'.
- Verify that no E-Document has been created for the sales invoice.
Additional context
The suggested approach is not ideal as it will not provide the user with sufficient info on why the e-document could not be created and how to fix it. However, making the system throw when the document type is not supported will most likely break some behavior, and there also might be other reasons for why the e-document cannot created.
I will provide a fix for a bug
Describe the issue
When manually creating an E-Document from a posted document page via action Related - E-Document - Create, if the system does not create an E-Document it still shows the message 'The e-document has been created.'.
There are cases when the e-document cannot be created due to a configuration error (for example, when a Document Sending Profile is not set up), in which case the system displays the corresponding error message.
However, there is a case when the system fails to create the e-document because the document type is not supported by the E-Document Service (which is configured in E-Document Service Supported Source Document Types), and it does not return an error, but rather just exists with false.
Expected behavior
The code in the action to manually create the E-Document from a posted document should check if an e-document has actually been created, and show a message 'Could not create the E-Document' if it was not and there is no explicit exception.
Steps to reproduce
Additional context
The suggested approach is not ideal as it will not provide the user with sufficient info on why the e-document could not be created and how to fix it. However, making the system throw when the document type is not supported will most likely break some behavior, and there also might be other reasons for why the e-document cannot created.
I will provide a fix for a bug