Function EN Version 5.00

@ReplicateWithFormulaWithFieldProtection

Database NotesAdmin NotesSystem Replication

Syntax

@ReplicateWithFormulaWithFieldProtection(DBHANDLE1;DBHANDLE2;FORMULA3;FNLIST4;FIELDNAMELIST1;FIELDNAMELIST2);
@ReplicateWithFormulaWithFieldProtection(DBHANDLE1;DBHANDLE2;FORMULA3;FNLIST4;FIELDNAMELIST1;FIELDNAMELIST2;NOTECLASSES5;FNREPLICATIONFLAGS6);
@ReplicateWithFormulaWithFieldProtection(DBHANDLE1;DBHANDLE2;FORMULA3;FNLIST4;FIELDNAMELIST1;FIELDNAMELIST2;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 FORMULA3 are replicated.
FNLIST4 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

FNLIST4:

Bit   HEX   Meaning
01   0001   Read
02   0002   Write
03   0004   Modify
04   0008   Delete

The optional parameter NOTECLASSES NOTECLASSES5 is used to restrict the documents considered in the selection formula TEXT FORMULA3. If parameter 5 is not specified, the selection formula TEXT 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.

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: @ReplicateWithFormulaWithFieldProtection(DBHANDLE1;DBHANDLE2;FORMULA3;FNLIST4;FIELDNAMELIST1;FIELDNAMELIST2;NOTECLASSES5;FNREPLICATIONFLAGS6;FNLISTERROR7);

/*
Example replication script with field protections.

This script opens two Notes databases and replicates selected documents
between them using a formula.
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{
   /* Select the documents to be replicated. Only entries of the "Mustermann" family are replicated! */
   Formula:="SELECT Form=\"MySqlAmount\" & @Right(Name;\" \")=\"Mustermann\"";

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

   /* 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 matching the formula while respecting
      the protected field lists for both databases. */

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