Function EN Version 5.00

@ReplicateWithFieldProtection

Database NotesAdmin NotesSystem Replication

Syntax

@ReplicateWithFieldProtection(DBHANDLE1;DBHANDLE2;FNLIST3;FIELDNAMELIST1;FIELDNAMELIST2);
@ReplicateWithFieldProtection(DBHANDLE1;DBHANDLE2;FNLIST3;FIELDNAMELIST1;FIELDNAMELIST2;FNREPLICATIONFLAGS4);
@ReplicateWithFieldProtection(DBHANDLE1;DBHANDLE2;FNLIST3;FIELDNAMELIST1;FIELDNAMELIST2;FNREPLICATIONFLAGS4;FNLISTERROR5);

Description

Replicates the database referenced by DBHANDLE1 with the database referenced by DBHANDLE2. FNLIST3 contains the replication rights. The first element specifies the rights for replication in the first database, and the second element specifies the rights for the second database.
The databases do not have to be replicas of each other!

FIELDNAMELIST1 and FIELDNAMELIST2 can be used to specify field names whose values should be preserved in the respective database. During replication, these fields are not overwritten by fields with the same name from the other database.

TEXT/TEXTLIST FIELDNAMELIST1:
Specifies the names of the fields that should be preserved in the documents of DB1.
Fields with the same name from documents in DB2 are not transferred when replicating to DB1.

TEXT/TEXTLIST FIELDNAMELIST2:
Specifies the names of the fields that should be preserved in the documents of DB2.
Fields with the same name from documents in DB1 are not transferred when replicating to DB2.

A FNLIST is returned:

element   Meaning
1   UpdateCount DBHANDLE1
2   CreateCount DBHANDLE1
3   DeleteCount DBHANDLE1
4   UpdateCount DBHANDLE2
5   CreateCount DBHANDLE2
6   DeleteCount DBHANDLE2

FNLIST3:

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.

FNREPLICATIONFLAGS4
:

Bit   HEX   Meaning
01   0001   Localize links (Doc;View;DB) in databases with different replica IDs.

FNLISTERROR5:
When the optional return parameter FNLISTERROR5 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: @ReplicateWithFieldProtection(DBHANDLE1;DBHANDLE2;FNLIST3;FIELDNAMELIST1;FIELDNAMELIST2;FNREPLICATIONFLAGS4;FNLISTERROR5);

/*
Example replication script with field protections.

This script opens two Notes databases and replicates them.
Specific fields can be protected from being overwritten during replication.

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{
   /* 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);

   /* Define fields that must not be overwritten in the respective database. */
   SrcDB_ProtectedFieldsList:="FieldLocalToThisDB";
   DstDB_ProtectedFieldsList:="FieldLocalToThisDB";

   /* Combine the rights definitions for source and target database. */
   RightsList:=SrcDB_RghtsBitVector:DstDB_RghtsBitVector;

   /* Replicate all documents while respecting
      the protected field lists for both databases. */

   Ret:=@ReplicateWithFieldProtection(SrcDBh;DstDBh;RightsList;SrcDB_ProtectedFieldsList;DstDB_ProtectedFieldsList;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.