AddFollowSaveFileRequest
Min. Release xx.3.241219.1
Description
Creates a new “ECM queue” entry and links it
to the previous queue entry (which is the base queue entry for the second file) and
the base queue entry.
Syntax
procedure AddFollowSaveFileRequest(var TempECMJnlLine: Record "ECM Document Journal Line" ; [var TempMetadataFieldValue: Record "ECM Metadata Field Value" ;] var ECMDocDef: Record "ECM Document Definition" ; MainRecordVariant: Variant; var BaseTransactionNo: BigInteger; var PreviousTransactionNo: BigInteger; var TransactionNo: BigInteger) ErrorCode: Integer |
Parameters
Variable: TempECMJnlLine
Type: Record “ECM Document Journal Line” temporary
Used as a data object (“container”) to transfer data to a function for all fields that must 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.
Optionally, fields such as “External Document Number,” “Document Category,” and other fields can be transferred to the data container.
[Optional] Variable: TempMetadataFieldValue
Type: Record “ECM Metadata Field Value” temporary
Used as a data object (“container”) to transfer data to a function for all fields that are transferred to the archive (repository) as metadata. By default, it is sufficient to transfer the table empty, as the metadata is prepared using the MainRecord and the document definition. Alternatively, the desired deviating or additional metadata can be prepared here.
Variable: ECMDocDef
Type: Record “ECM Document Definition”
ECM document definition for the data record. The correct document definition for the data record is searched for using the API function FindDocDefByRRef.
If necessary, different values can be transferred to the document definition data record, e.g., “document category.”
BaseTransactionNo
Type: BigInteger
The number of the base ECM queue entry.
PreviousTransactionNo
Type: BigInteger
The number of the previous
Example:
// get the document definition for the current record
Found := ECMapi
.
FindDocDefByRRef(CurrECMDocDef, MainRecordVariant, "ECM Purpose
of
use"::Email);
if
not
Found
then
exit;
// add the file to the Temp ECM Journal Line
ErrorCode := ECMapi
.
InitTempECMJnlLine4SaveFileRequest(TempECMJnlLine, FileInStream, FileName);
if
ErrorCode <>
0
then
begin
ECMapi
.
WriteLog(
'InitTempECMJnlLine4SaveFileRequest Failed'
,
''
, ErrorCode, Enum::"ECM Message
Type
"::Warning, MainRecordVariant,
0
,
0
)
exit;
end
;
// add custom data to the ECM Journal Line, if needed
TempECMJnlLine."ECM Document ID (Barcode)" := CopyStr(
'MY CUSTOM BARCODE'
,
2
,
36
);
// create the ECM Queue
ErrorCode := ECMapi
.
SaveFileRequest(TempECMJnlLine, ECMDocDef, CurrRecordRef, BaseTransactionNo);
if
ErrorCode <>
0
then
exit;
// initialize the PreviousTransactionNo with the BaseTransactionNo
PreviousTransactionNo := BaseTransactionNo;
// create 2. Temp ECM Journal Line for 2. File
ErrorCode := ECMapi
.
InitTempECMJnlLine4SaveFileRequest(TempECMJnlLine2, File2InStream, FileName2);
if
ErrorCode <>
0
then
begin
ECMapi
.
WriteLog(
'2. InitTempECMJnlLine4SaveFileRequest Failed'
,
''
, ErrorCode, Enum::"ECM Message
Type
"::Error, MainRecordVariant,
0
,
0
)
exit;
end
;
// create the 2. ECM Queue Follow Entry
ErrorCode := ECMapi
.
AddFollowSaveFileRequest(TempECMJnlLine2, ECMDocDef, MainRecordVariant, BaseTransactionNo, PreviousTransactionNo, TransactionNo);
if
ErrorCode <>
0
then
exit;
// update PreviousTransactionNo with the TransactionNo generated before
PreviousTransactionNo := TransactionNo;
// create 3. Temp ECM Journal Line for 3. File
ErrorCode := ECMapi
.
InitTempECMJnlLine4SaveFileRequest(TempECMJnlLine3, File3InStream, FileName3);
if
ErrorCode <>
0
then
begin
ECMapi
.
WriteLog(
'3. InitTempECMJnlLine4SaveFileRequest Failed'
,
''
, ErrorCode, Enum::"ECM Message
Type
"::Error, MainRecordVariant,
0
,
0
)
exit;
end
;
// create the 3. ECM Queue Follow Entry
ErrorCode := ECMapi
.
AddFollowSaveFileRequest(TempECMJnlLine3, ECMDocDef, MainRecordVariant, BaseTransactionNo, PreviousTransactionNo, TransactionNo);
if
ErrorCode <>
0
then
exit;
// release the ECM Queue
ECMapi
.
ReleaseECMRepositoryRequest(BaseTransactionNo);