@ReplicateWithFormula
Syntax
@ReplicateWithFormula(DBHANDLE1;DBHANDLE2;FORMULA3;FNLIST4);
@ReplicateWithFormula(DBHANDLE1;DBHANDLE2;FORMULA3;FNLIST4;NOTECLASSES5;FNREPLICATIONFLAGS6);
@ReplicateWithFormula(DBHANDLE1;DBHANDLE2;FORMULA3;FNLIST4;NOTECLASSES5;FNREPLICATIONFLAGS6;FNLISTERROR7);
Description
Replicates the database referenced by DBHANDLE1 with the database referenced by DBHANDLE2. Only documents that match the Notes-compatible selection formula TEXT/TEXTLIST FORMULA3 are replicated. FORMULA3 can be passed as TEXT or TEXTLIST. If a TEXTLIST is passed, the first element is used as the selection formula for the database referenced by DBHANDLE1, and the second element is used accordingly for the database referenced by DBHANDLE2. FNLIST4 contains the replication rights. The first element specifies the replication rights for the first database, and the second element specifies the replication rights for the second database. The databases do not have to be replicas of each other. FNREPLICATIONFLAGS6 can be used to enable or disable replicator options.
A FNLIST is returned:
Element Meaning
1 UpdateCount DBHANDLE1
2 CreateCount DBHANDLE1
3 DeleteCount DBHANDLE1
4 UpdateCount DBHANDLE2
5 CreateCount DBHANDLE2
6 DeleteCount DBHANDLE2
FNLIST4:
Bit HEX Meaning
01 0001 Read
02 0002 Write
03 0004 Modify
04 0008 Delete
Note:
When replication uses asymmetric rights assignments, behavior may occur that appears contradictory at first glance.
Example: Database A is allowed to replicate documents to database B. However, database B does not have delete rights in database A.
If a document is first replicated from A to B and then deleted in B, a deletion stub is created in B. This deletion stub remains in the database until the CutOffTD; see also @GetDBReplicaInfo.
Because B does not have delete rights in A, the deletion is not replicated from B to A. The original document therefore still remains in A.
However, as long as the deletion stub exists in B, the document that still exists in A is also not replicated again from A to B. For the replication logic, the document in B is still considered deleted during this period.
Only after the deletion stub in B has been removed after the CutOffTD has expired can the document be transferred from A to B again during a later replication. This can make it appear as if the document suddenly reappears in B.
This behavior corresponds to the behavior of the Domino Replicator when replication rights are assigned asymmetrically.
The optional parameter NOTECLASSES NOTECLASSES5 is used to restrict the documents considered in the selection formula FORMULA3. If NOTECLASSES5 is not specified, the selection formula FORMULA3 is applied to documents of NOTECLASS 1 (Documents).
NOTECLASSES5:
DEC BIT Meaning
00000 XX No Notes no documents
00001 01 Documents data documents
00002 02 Policy-Note About database document
00004 03 Form-Note form design documents
00008 04 View-Note view design documents
00016 05 Icon-Note icon document
00032 06 Design-Collection-Note view documents
00064 07 ACL-Info-Note ACL info document
00128 08 Help-Index-Note
00256 09 Help-Note help database document
00512 10 Filter-Note macro design documents
01024 11 field-Note field design documents
02048 12 Replication-Note replication documents
04096 13 Privat_Design private design documents
32768 16 Default-Note of Each default document of each type
32767 01-15 Notes all documents
32766 02-15 All Non-Document-Notes all non-data documents
(To specify multiple document classes, add the values of the relevant classes or build them using @BitVektor.)
FNREPLICATIONFLAGS6:
Bit HEX Meaning
01 0001 Localize links (Doc;View;DB) in databases with different replica IDs.
02 0002 Reserved
03 0004 "NOTE changed during the REPLICATION process, …" error messages are not output.
FNLISTERROR7:
When the optional return parameter FNLISTERROR7 is used, error statisics are returned in it.
element Meaning
1 Error UpdateCount DBHANDLE1
2 Error CreateCount DBHANDLE1
3 Error DeleteCount DBHANDLE1
4 Error UpdateCount DBHANDLE2
5 Error CreateCount DBHANDLE2
6 Error DeleteCount DBHANDLE2
Example: @ReplicateWithFormula(DBHANDLE1;DBHANDLE2;FORMULA3;FNLIST4;NOTECLASSES5;FNREPLICATIONFLAGS6;FNLISTERROR7);
/*
Example replication script with formula of databases with different
replica ids.
This script opens two Notes databases and replicates selected documents
between them using a formula.
The script logs the number of updated, created, and deleted documents,
as well as the corresponding error counts for both databases.
*/
SrcDBPath:="test\\testdb1.nsf";
DstDBPath:="test\\testdb2.nsf";
/* Open the source and target databases. */
SrcDBh:=@OpenDB(SrcDBPath);
DstDBh:=@OpenDB(DstDBPath);
/* Build labels for the replication result counters. */
RetLabels:=("Number of docs "+@Explode("updated in ;created in ;deleted in ";";")+SrcDBPath+": "):
("Number of docs "+@Explode("updated in ;created in ;deleted in ";";")+DstDBPath+": ");
/* Build labels for the replication error counters. */
RetErrorListsLabels:=("Number of errors while "+@Explode("updating in ;creating in ;deleting in ";";")+SrcDBPath+": "):
("Number of errors while "+@Explode("updating in ;creating in ;deleting in ";";")+DstDBPath+": ");
/* If one of the databases could not be opened, log the corresponding error. */
IF(@IsError(SrcDBh;DstDBh)){
IF(@IsError(SrcDBh)){
@LogReport(SrcDBh;3);
}
IF(@IsError(DstDBh)){
@LogReport(DstDBh;3);
}
}ELSE{
/* Select the documents to be replicated. Only entries of the "Mustermann" family are replicated! */
Formula:="SELECT Form=\"MySqlAmount\" & @Right(Name;\" \")=\"Neumann\"";
/* Replicate regular data documents. */
NoteClasses:=1;
/* Use default replication behavior. */
ReplicationFlags:=0;
/* Define the replication rights for the source and target databases. All rights granted! */
SrcDB_RghtsBitVector:=@BitVektor(1:2:3:4);
DstDB_RghtsBitVector:=@BitVektor(1:2:3:4);
/* Combine the rights definitions for source and target database. */
RightsList:=SrcDB_RghtsBitVector:DstDB_RghtsBitVector;
/* Replicate all documents matching the formula. */
Ret:=@ReplicateWithFormula(SrcDBh;DstDBh;Formula;RightsList;NoteClasses;ReplicationFlags;RetErrorLists);
/* Log the replication result counters. */
@LogReport(@Implode(RetLabels+@Text(Ret);@NewLine);3);
/* Log the replication error counters. */
@LogReport(@Implode(RetErrorListsLabels+@Text(RetErrorLists);@NewLine);3);
} /* END IF(@IsError(SrcDBh;DstDBh)) */
/* Close the source database if it was opened successfully. */
IF(!@IsError(SrcDBh)){
SrcDBh:=@CloseDB(SrcDBh);
}
/* Close the target database if it was opened successfully. */
IF(!@IsError(DstDBh)){
DstDBh:=@CloseDB(DstDBh);
}
Note : This text was machine-translated and may contain inaccuracies.
