Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 有人能修复我的函数吗?_Function_Lotus Notes_Lotusscript - Fatal编程技术网

Function 有人能修复我的函数吗?

Function 有人能修复我的函数吗?,function,lotus-notes,lotusscript,Function,Lotus Notes,Lotusscript,我正在尝试编写一个验证函数,用于检查正在添加的条目是否已经存在于数据集中 但是搜索并没有找到它——我可以继续在数据库中输入相同的约会 如果有人能发现我的代码不起作用的原因,我将非常感谢你的帮助 谢谢 Public Function checkNewLocationRecordIsUnique As Boolean Dim s As New NotesSession Dim w As New NotesUIWorkspace Dim db As NotesDatabase Dim selectV

我正在尝试编写一个验证函数,用于检查正在添加的条目是否已经存在于数据集中

但是搜索并没有找到它——我可以继续在数据库中输入相同的约会

如果有人能发现我的代码不起作用的原因,我将非常感谢你的帮助

谢谢

Public Function checkNewLocationRecordIsUnique As Boolean

Dim s As New NotesSession
Dim w As New NotesUIWorkspace
Dim db As NotesDatabase
Dim selectView As NotesView
Dim key(0 To 4) As Variant
Dim entry As NotesViewEntry
Dim entryIsNotUniqueMsg As String
Let entryIsNotUniqueMsg = "There is already an entry for this date/time. Please modify your entry's details or cancel the existing entry to continue."
Dim thisDoc As NotesDocument
Dim uiDoc As NotesUIDocument
Set uidoc = w.CurrentDocument
Set thisDoc = uidoc.Document

'get handle to database and check we've found the database
Set db = s.CurrentDatabase
If Not db Is Nothing Then

    'get handle to view to lookup field combination in
    Set selectView = db.GetView("allLocationRecordsByName")
    Call selectView.Refresh()

    If Not selectView Is Nothing Then

        'populate "key" - an array of variants - with fields to use as match criteria

    key(0) = thisDoc.PersonName
    key(1) = thisDoc.StartDate
    key(2) = thisDoc.EndDate
    key(3) = thisDoc.StartTime
    key(4) = thisDoc.EndTime
    Set entry = selectView.GetEntryByKey(thisDoc.key, True)

        'lookup the combination in the view to see if it already exists
        If entry Is Nothing Then
            MsgBox "No conflicting entry found! Record added.", 0, "Notice"

            'if it wasn't found then the record is unique so return true
            checkNewLocationRecordIsUnique = True
        Else
            'else the combination was found - but lets make sure that it's not this one
            '(this could happen if the user is editing an existing record)
            'compare uids of both thisDoc and the doc entry that was found

            If entry.document.UniversalID = thisDoc.UniversalID Then
                checkNewLocationRecordIsUnique = True
            MsgBox "An Entry Was Found, But It Was The Entry! Record added.", 0, "Notice"

                'else it WAS found as a separate document so the function returns false
            Else
                MsgBox entryIsNotUniqueMsg, 0, "Error: Entry Is Not Unique"
                    checkNewLocationRecordIsUnique = False  
            End If
        End If
    End If  
End If
End Function

thisDoc.PersonName
返回一个数组,您可能需要使用

key(0) = thisDoc.PersonName(0)
key(1) = thisDoc.StartDate(0)
key(2) = thisDoc.EndDate(0)
key(3) = thisDoc.StartTime(0)
key(4) = thisDoc.EndTime(0)

thisDoc.PersonName
返回一个数组,您可能需要使用

key(0) = thisDoc.PersonName(0)
key(1) = thisDoc.StartDate(0)
key(2) = thisDoc.EndDate(0)
key(3) = thisDoc.StartTime(0)
key(4) = thisDoc.EndTime(0)

view allLocationRecordsByName是否按搜索键中包含的每列排序


请参阅文档。

视图allLocationRecordsByName是否按搜索键中包含的每列进行排序


请参阅文档。

您正在使用五行代码来填充名为key的本地变量数组,但实际上并没有将该数组用于GetEntryByKey调用

我猜你想让代码这么说:

Set entry = selectView.GetEntryByKey(key, True)
与此相反:

Set entry = selectView.GetEntryByKey(thisDoc.key, True)

您使用了五行代码来填充名为key的本地变量数组,但实际上并没有将该数组用于GetEntryByKey调用

我猜你想让代码这么说:

Set entry = selectView.GetEntryByKey(key, True)
与此相反:

Set entry = selectView.GetEntryByKey(thisDoc.key, True)

请定义“不工作”。错误消息…?哦,抱歉。我没有收到任何错误消息-它只是没有找到任何匹配项,即使它正在搜索的视图中存在匹配项。这意味着,即使我没有收到任何错误,函数也不会执行任何验证,并且即使已经存在相同的记录,每个条目都会添加到数据库中。请定义“不工作”。错误消息…?哦,抱歉。我没有收到任何错误消息-它只是没有找到任何匹配项,即使它正在搜索的视图中存在匹配项。这意味着,即使我没有收到任何错误,函数也不会执行任何验证,并且每个条目都会添加到数据库中,即使已经存在相同的记录。这两条建议结合在一起使其工作。谢谢你们,这两条建议合在一起就行了。谢谢你们,谢谢贾斯珀。我用了那个建议,把(thisDoc.keys,True)改成了(keys,True),因为我打错了电话。现在可以了,谢谢你,贾斯珀。我用了那个建议,把(thisDoc.keys,True)改成了(keys,True),因为我打错了电话。现在它起作用了。