Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ codeunit 6135 "E-Document WorkFlow Processing"
var
WorkflowStepArgument: Record "Workflow Step Argument";
EDocumentService: Record "E-Document Service";
EDocServiceStatus: Record "E-Document Service Status";
EDocument: Record "E-Document";
EDocExport: Codeunit "E-Doc. Export";
WorkflowManagement: Codeunit "Workflow Management";
Expand All @@ -481,6 +482,13 @@ codeunit 6135 "E-Document WorkFlow Processing"

EDocumentService.Get(WorkflowStepArgument."E-Document Service");

// If the E-Document has already been exported, skip re-exporting it.
if EDocServiceStatus.Get(EDocument."Entry No", EDocumentService.Code) then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you want to reexport?
Is that possible.

Try post document: Then it gets exported, then you change some editable field on posted document, and want that change to reflect in the e-document. What do you do in this case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our fix is in EDocumentWorkFlowProcessing.ExportEDocument() — the workflow response handler. It only runs when the workflow engine automatically fires the Export response step. The skip logic prevents a duplicate within the same workflow execution, because CreateEDocument already pre-exports the document before the workflow fires its Export response.

Manual re-export ("Recreate Document" action on the E-Document page) calls EDocExport.Recreate()EDocExport.ExportEDocument() directly. This path never goes through the workflow processing layer, so the status check we added is never hit.

Manual Re-export (unaffected):
  Page Action "Recreate" -> EDocExport.Recreate() -> EDocExport.ExportEDocument() -> always executes

Workflow auto-trigger (what we fixed):
  Workflow Engine -> EDocumentWorkFlowProcessing.ExportEDocument() ->  [status check -> skip if already Exported]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Correct me if I misunderstand this function)

if EDocServiceStatus.Status = Enum::"E-Document Service Status"::Exported then begin
WorkflowManagement.HandleEventOnKnownWorkflowInstance(EDocWorkflowSetup.EventEDocExported(), EDocument, EDocument."Workflow Step Instance ID");
exit;
end;

if EDocExport.ExportEDocument(EDocument, EDocumentService) then
WorkflowManagement.HandleEventOnKnownWorkflowInstance(EDocWorkflowSetup.EventEDocExported(), EDocument, EDocument."Workflow Step Instance ID");
end;
Expand Down
Loading
Loading