@@ -110,6 +110,37 @@ codeunit 6135 "E-Document WorkFlow Processing"
110110 Telemetry. LogMessage( ' 0000LBW' , EDocTelemetryProcessingEndScopeLbl, Verbosity ::Normal, DataClassification ::OrganizationIdentifiableInformation, TelemetryScope::All) ;
111111 end ;
112112
113+ internal procedure ExportEDocument( var EDocument: Record "E-Document"; WorkflowStepInstance: Record "Workflow Step Instance")
114+ var
115+ WorkflowStepArgument: Record "Workflow Step Argument";
116+ EDocumentService: Record "E-Document Service";
117+ begin
118+ if not ValidateFlowStep( EDocument, WorkflowStepArgument, WorkflowStepInstance) then
119+ exit ;
120+ EDocumentService. Get( WorkflowStepArgument. "E-Document Service") ;
121+ ExportEDocument( EDocument, EDocumentService) ;
122+ end ;
123+
124+ internal procedure ExportEDocument( var EDocument: Record "E-Document"; EDocumentService: Record "E-Document Service")
125+ var
126+ Telemetry: Codeunit Telemetry;
127+ EDocumentHelper: Codeunit "E-Document Processing";
128+ FeatureTelemetry: Codeunit "Feature Telemetry";
129+ TelemetryDimensions: Dictionary of [Text , Text ];
130+ begin
131+ FeatureTelemetry. LogUptake( ' 0000KZ0' , EDocumentHelper. GetEDocTok() , Enum ::"Feature Uptake Status"::Used) ;
132+ EDocumentHelper. GetTelemetryDimensions( EDocumentService, EDocument, TelemetryDimensions) ;
133+ Telemetry. LogMessage( ' 0000LB6' , EDocTelemetryProcessingStartScopeLbl, Verbosity ::Normal, DataClassification ::OrganizationIdentifiableInformation, TelemetryScope::All, TelemetryDimensions) ;
134+
135+ if IsEdocServiceUsingBatch( EDocumentService) then
136+ DoBatchExport( EDocument, EDocumentService)
137+ else
138+ DoExport( EDocument, EDocumentService) ;
139+
140+ FeatureTelemetry. LogUsage( ' 0000KZ1' , EDocumentHelper. GetEDocTok() , ' E-Document has been exported.' ) ;
141+ Telemetry. LogMessage( ' 0000LB7' , EDocTelemetryProcessingEndScopeLbl, Verbosity ::Normal, DataClassification ::OrganizationIdentifiableInformation, TelemetryScope::All) ;
142+ end ;
143+
113144 internal procedure HandleNextEvent( var EDocument: Record "E-Document")
114145 var
115146 WorkflowManagement: Codeunit "Workflow Management";
@@ -190,6 +221,52 @@ codeunit 6135 "E-Document WorkFlow Processing"
190221 end ;
191222 end ;
192223
224+ local procedure DoBatchExport( var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service")
225+ var
226+ TempEDocMappingLogs: Record "E-Doc. Mapping Log" temporary ;
227+ EDocExport: Codeunit "E-Doc. Export";
228+ EDocIntMgt: Codeunit "E-Doc. Integration Management";
229+ EDocumentLog: Codeunit "E-Document Log";
230+ EDocumentBackgroundjobs: Codeunit "E-Document Background Jobs";
231+ EDocumentErrorHelper: Codeunit "E-Document Error Helper";
232+ TempBlob: Codeunit "Temp Blob";
233+ EDocServiceStatus: Enum "E-Document Service Status";
234+ BeforeExportEDocErrorCount: Dictionary of [Integer , Integer ];
235+ IsAsync, IsHandled, AnyErrors : Boolean ;
236+ ErrorCount: Integer ;
237+ begin
238+ EDocServiceStatus := Enum ::"E-Document Service Status"::"Pending Batch";
239+ EDocumentLog. InsertLog( EDocument, EDocumentService, Enum ::"E-Document Service Status"::"Pending Batch") ;
240+ EDocumentProcessing. ModifyServiceStatus( EDocument, EDocumentService, EDocServiceStatus) ;
241+ EDocumentProcessing. ModifyEDocumentStatus( EDocument) ;
242+
243+ if EDocumentService. "Batch Mode" = EDocumentService. "Batch Mode"::Recurrent then
244+ exit ;
245+ if EDocumentService. "Batch Mode" = EDocumentService. "Batch Mode"::Threshold then begin
246+ if not IsThresholdBatchCriteriaMet( EDocumentService, EDocument) then
247+ exit ;
248+ end else begin
249+ OnBatchSendWithCustomBatchMode( EDocument, EDocumentService, IsHandled) ;
250+ if not IsHandled then
251+ Error( NotSupportedBatchModeErr, EDocumentService. "Batch Mode") ;
252+ exit ;
253+ end ;
254+
255+ EDocExport. ExportEDocumentBatch( EDocument, EDocumentService, TempEDocMappingLogs, TempBlob, BeforeExportEDocErrorCount) ;
256+
257+ AnyErrors := false;
258+ EDocument. FindSet() ;
259+ repeat
260+ BeforeExportEDocErrorCount. Get( EDocument. "Entry No", ErrorCount) ;
261+ if ( EDocumentErrorHelper. ErrorMessageCount( EDocument) > ErrorCount) then
262+ AnyErrors := true;
263+ until EDocument. Next() = 0 ;
264+
265+ InsertLogsForThresholdBatch( EDocument, EDocumentService, TempEDocMappingLogs, TempBlob, AnyErrors) ;
266+ if not AnyErrors then
267+ HandleNextEvent( EDocument) ;
268+ end ;
269+
193270 local procedure InsertLogsForThresholdBatch( var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; var TempEDocMappingLogs: Record "E-Doc. Mapping Log" temporary ; var TempBlob: Codeunit "Temp Blob"; Error: Boolean )
194271 var
195272 EDocMappingLog: Record "E-Doc. Mapping Log";
@@ -246,6 +323,14 @@ codeunit 6135 "E-Document WorkFlow Processing"
246323 HandleNextEvent( EDocument) ;
247324 end ;
248325
326+ local procedure DoExport( var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service")
327+ var
328+ EDocExport: Codeunit "E-Doc. Export";
329+ begin
330+ if EDocExport. ExportEDocument( EDocument, EDocumentService) then
331+ HandleNextEvent( EDocument) ;
332+ end ;
333+
249334 local procedure ValidateFlowStep( var EDocument: Record "E-Document"; var WorkflowStepArgument: Record "Workflow Step Argument"; WorkflowStepInstance: Record "Workflow Step Instance") : Boolean
250335 var
251336 EDocErrorHelper: Codeunit "E-Document Error Helper";
0 commit comments