NotesReplicationEntry - Lotus Notes

时间:2016-12-14 14:35:46

标签: lotus-notes lotusscript lotus

我正在尝试使用LotusScript设置选择性复制,但我无法保存它。日志显示没有错误,脚本完成且没有错误。副本已创建,但不是我的选择性复制集。

%REM
    Agent createRenewalDB
    Created Dec 14, 2016 by 
    Description: Comments for Agent
%END REM
Option Public

Use "xxx Routines"
Sub Initialize


    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim s As New NotesSession
    Dim flag As Boolean
    Dim renDb As NotesDatabase
    Dim renFP As String
    Dim renHubDb As NotesDatabase
    Dim sQuote As String
    Dim nowt As String
    Dim pos As Long
    Dim client As String
    Dim frm As String
    Dim L As Long
    Dim P1 As String
    Dim P2 As String
    Dim item As NotesItem
    Dim renYN As String
    Dim agent As NotesAgent
    Set agent = s.CurrentAgent


    Print("createRenewalDB starting")

    Set db = s.Currentdatabase
    Set doc = db.GetDocumentByID(agent.ParameterDocID)

    'Print("got doc")
    client = doc.getItemValue("Client")(0)
    nowt = ""
    sQuote = """"
    pos = 1

    Dim tmp1 As String

    'Print("set vars")

    tmp1 = doc.getItemValue("SearchFormula")(0)

    'Print("got search formula")

    frm = StrLeft(StrRight(tmp1,"ix_client;"),")")

    '### strip out quotation marks
    Do Until pos = 0
        L = Len(frm)
        pos& = InStr(1,frm,sQuote)

        If pos <> 0 Then
            P1 = Left(frm,pos - 1) ' Part 1 of the text string
            P2 = Right(frm,L- pos )
            frm = P1 & nowt & P2
        End If
    Loop

    'Print("stripped out the rubbish")
    '#### Setup a new Renewals document if none exixts and Renewals has been selected

    Set item = doc.getfirstitem("EnabledApps")

    renYN = item.text

    If InStr(renYN, "32") > 0  Then

        '##### Get the Renewals Quotes Db

        Set renHubDb = Get_Specific_Db_Object("Renewal Quotes", "xxx-01")

        If renHubDb Is Nothing Then
            MsgBox("Fail: Could not get the Renewals Quotes database on Hub, exiting renewals created.")
            Exit Sub
        End If

        renFP = doc.getItemvalue("Renewals")(0)

        'Msgbox("Renewals to be set up " + renFP)

        Set renDb = s.GetDatabase("",renFP,False)

        If renDb Is Nothing Then '#### No replica, so create one
            Print("Creating a replica for " + client)
            Set renDb = renHubDb.CreateReplica("xxx-01",renFP)

            renDb.Title = client

            Dim rep As NotesReplication
            Dim re As NotesReplicationEntry
            Dim server As String

            server = "xxx-xxx-01"

            Set rep = renDb.ReplicationInfo '## Get the replication info
            Set re = rep.GetEntry("-",server,True) '## get the replication entry - true creates it

            re.Formula = "SELECT @Contains(client;" &"""" & frm & """" &  ")" '## add the selective replication
            Print("selective replication formula " + re.Formula)

            '## save both
            Call re.Save 
            Call rep.Save()


            Print(re.Formula) '## formula is still set correctly at this point

        End If

        If renDb Is Nothing Then
            MsgBox("Could not create a replicate for " + client)
            Exit Sub
        End If


    Else
        MsgBox("No Renewals " + renYN)

    End If


    Print("###########################################Finished creating the replica - agent")

End Sub

有什么想法吗?

Lotus Notes 9.0.1 Lotus Domino 9.0.1

代码位于安全选项卡上具有完全管理员访问权限的代理中。

由于

格雷姆

0 个答案:

没有答案