SaveFileRequest
Description
Creates an entry in the ECM queue with the passed file. (The file is passed as a BOLB field in the TempECMJnlLine).
Syntax
[ErrorCode:= ] SaveFileRequest(var TempECMJnlLine: Record
"ECM Document Journal Line"
; var ECMDocDef: Record
"ECM Document Definition"
; MainRecordVariant: Variant; var TempMetadataFieldValue: Record
"ECM Metadata Field Value"
; var TransactionNo: BigInteger)
Parameters
Variable: TempECMJnlLine
Type: Record "ECM Document Journal Line" temporary
Used as a data object ("container") to pass data to a function, for all fields that need to be filled in the document items. By default, the document items are filled using the MainRecord and the document definition.
Filename, BLOB and MD5 hash are mandatory fields
Variable: ECMDocDef
Type: Record "ECM Document Definition"
ECM document definition for the record. The correct document definition for the record is searched for with the API function FindDocDefByRRef . Values different from or additional to the found document definition can be added to the record if needed.
MainRecordVariant
Type: Variant
MainRecord (record) is entered into the ECM queue and is required for processing the metadata.
Tip: The MainRecord can be passed as Record, RecordID or RecordRef.
Variable: TempMetadataFieldValue
Type: Record "ECM Metadata Field Value" temporary
Used as a data object ("container") to pass data to a function, for all fields that will be passed as metadata to the archive (repository). By default, it is sufficient to pass the table empty, since the metadata is prepared using the MainRecord and the document definition. Alternatively, the desired deviating or additional metadata can be prepared here.
Variable: TransactionNo
Type: BigInteger
ECM queue transaction no. that is returned.
With the transaction number and the ReleaseECMRepositoryRequest function the ECM queue entry is released for further processing.
Return Value:
ErrorCode
Type: Integer
ErrorCode = 0 and TransactionNo <> 0 if the operation was successful.
With the function ShowMessage the ErrorCodes can be displayed and with the function WriteLog they can be logged.
Example:
/// <summary>
/// StoreDocument2ECMQueue.
/// </summary>
/// <param name="MainRecordVariant">Variant.</param>
/// <param name="TempBlob">Codeunit "Temp Blob".</param>
/// <param name="FileName">Text[250].</param>
local procedure StoreDocument2ECMQueue(MainRecordVariant: Variant; TempBlob: Codeunit
"Temp Blob"
; FileName: Text[
250
])
var
ECMDocDef: Record
"ECM Document Definition"
;
TempECMJnlLine: Record
"ECM Document Journal Line"
temporary;
TempMetadataFieldValue: Record
"ECM Metadata Field Value"
temporary;
ECMapi: Codeunit
"ECM API"
;
NVOutStream: OutStream;
NVInStream: InStream;
TransactionNo: BigInteger;
ErrorCode: Integer;
begin
// https://docs.easy-cloud.de/365BC-cloud/de-DE/118033789.html
// Sucht eine ECM Dokumentdefinition anhand der Tabellennummer, Tabellenbelegart und einem Startdatum (Gültigkeitsdatum) einer Dokumentdefinition (in der jüngsten Vergangenheit).
//
if
ECMapi.FindDocDefByRRef(ECMDocDef, MainRecordVariant, ECMDocDef.
"Purpose of use"
::
"Assign & File"
) then begin
//
if
TempBlob.HasValue() then begin
// Trägt die Datei von einem Blob in eine temporary "ECM Document Journal Line"
TempECMJnlLine.
"Line No."
:=
10000
;
TempECMJnlLine.Reset();
TempECMJnlLine.DeleteAll();
Clear(TempECMJnlLine);
TempECMJnlLine.File.CreateOutStream(NVOutStream);
TempBlob.CreateInStream(NVInStream);
CopyStream(NVOutStream, NVInStream);
TempECMJnlLine.
"File Name"
:= FileName;
// Generate MD5 Hash
TempECMJnlLine.GenerateMD5Hash();
// optional Fehlerhandling
IF TempECMJnlLine.md5 =
''
THEN
ECMApi.WriteLog(
''
,
''
,
75
, Enum::
"ECM Message Type"
::Warning, MainRecordVariant,
0
,
0
);
TempECMJnlLine.Insert();
// https://docs.easy-cloud.de/365BC-cloud/de-DE/118035412.html
// Erstellt einen Eintrag in der ECM-Warteschlange mit der übergebenen Datei. (Die Datei wird als BOLB-Feld in der TempECMJnlLine übergeben)
//
ErrorCode := ECMapi.SaveFileRequest(TempECMJnlLine, TempMetadataFieldValue, ECMDocDef, MainRecordVariant, TransactionNo);
//
if
ErrorCode <>
0
then
ECMApi.WriteLog(
''
,
''
, ErrorCode, Enum::
"ECM Message Type"
::Error, MainRecordVariant,
0
, TransactionNo)
else
if
TransactionNo <>
0
then
// https://docs.easy-cloud.de/365BC-cloud/de-DE/118033732.html
//Setzt den Status eines Eintrages in der ECM Warteschlange von begonnen auf anstehend.
//
ECMapi.ReleaseECMRepositoryRequest(TransactionNo);
//
end;
end;
end;