Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7405481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:24:39+00:00 2026-05-29T05:24:39+00:00

Can someone offer some help on this? I’m getting an ‘invalid key value type’

  • 0

Can someone offer some help on this? I’m getting an ‘invalid key value type’ error when trying to search a view using the userName variable as a key.

Is this because it’s the NotesName type? Is there any way to get around this? Any help appreciated. Thanks!

%REM
 Sub aiv_checkPersonIsValid
Description: 
Checks that the person(s) that have been entered into the location database are valid
members of the CCL Address Book

Function calls: N/A
Sub calls: N/A
Called in event: onChange (to populate fields)
Called in action: Save and Close, Save, Save And Add Another
Called by: co_countValuesAndPopulate() 

%END REM
Public Function aiv_checkPersonIsValid (userName As NotesName) As Boolean

Dim s As New NotesSession
Dim w As New NotesUIWorkspace
Dim peopleDb As NotesDatabase
Dim peopleView As NotesView
Dim peopleDoc As NotesDocument
Dim thisDoc As NotesDocument
Dim uidoc As NotesUIDocument
Dim key(0) As Variant
Dim noMatchFound As String
Let noMatchFound = "No match found for this name. Please choose a name from the      menu provided."
Dim PersonNameField As NotesItem        
'Dim userName As NotesDocument
Set uidoc = w.CurrentDocument
Set thisDoc = uidoc.Document        

    'get handle to People database and check we've found the database
    Set peopleDb=s.GetDatabase("****", "ccl\development\LocSysPeople.nsf")
    If Not peopleDb Is Nothing Then

            'get handle to view in People database and check we've found the view
            Set peopleView = peopleDb.GetView("All\LocSysLookup")
            If Not peopleView Is Nothing Then

                'Make the PersonNameField variable equal to the value of the first item in the Person Name Field
                Set PersonNameField = thisDoc.GetFirstItem("PersonName")

        ForAll pName In PersonNameField.Values
            'Start to loop through the PersonNameField and check that the names chosen exist in the people database 
            'lookup record in People database which matches the name in the PersonName field on this document   

            Set userName = New NotesName(pName)

            Set key(0) = userName

            'Set peopleDoc = peopleView.GetDocumentByKey(uidoc.Document.GetItemValue("PersonName")(0), True)
            Set peopleDoc = peopleView.GetDocumentByKey(key, True)

                    'If there is no match found to the document in the peopleDb, show a MsgBox
                    If peopleDoc Is Nothing Then
                                MsgBox "No match found in the CCL People Database for '" + pName.Common + "'. Please choose a valid name.", 0, "Error: No match found"
                    aiv_checkPersonIsValid=False
                    Exit Function
                    End If

        'End Loop   
        End ForAll

    End If
End If

End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:24:40+00:00Added an answer on May 29, 2026 at 5:24 am

    You seem to be using the userName variable multiple times for different purposes, once in the function definition and then changing the type later in the code. The code looks like it was ripped from a different function and adapted because the value being passed in it not the one your comparing in the code later, there is also nothing to set the return value of the function which is another error

    Here’s how I would write that function

    Public Function aiv_checkPersonIsValid As Boolean
    
        aiv_checkPersonIsValid=False
    
        Dim s As New NotesSession
    
        Dim w As New NotesUIWorkspace
    
        Dim uidoc As NotesUIDocument
        Set uidoc = w.CurrentDocument
    
        Dim thisDoc As NotesDocument
        Set thisDoc = uidoc.Document  
    
        Dim userName As NotesName
        Dim peopleDoc As NotesDocument
        Dim PersonNameField As NotesItem        
    
        'get handle to People database and check we've found the database
        Dim peopleDb As NotesDatabase
        Set peopleDb=s.GetDatabase("****", "ccl\development\LocSysPeople.nsf")
        If Not peopleDb Is Nothing Then
    
            'get handle to view in People database and check we've found the view
            Dim peopleView As NotesView
            Set peopleView = peopleDb.GetView("All\LocSysLookup")
            If Not peopleView Is Nothing Then
    
                'Make the PersonNameField variable equal to the value of the first item in the Person Name Field
                Set PersonNameField = thisDoc.GetFirstItem("PersonName")
    
                ForAll pName In PersonNameField.Values
                    'Start to loop through the PersonNameField and check that the names chosen exist in the people database 
                    'lookup record in People database which matches the name in the PersonName field on this document   
    
                    Set userName = New NotesName(pName)
                    Set peopleDoc = peopleView.GetDocumentByKey(userName.Abbreviated, True)
    
                    'If there is no match found to the document in the peopleDb, show a MsgBox
                    If peopleDoc Is Nothing Then
                        MsgBox "No match found in the CCL People Database for '" + pName.Common + "'. Please choose a valid name.", 0, "Error: No match found"
                        Exit Function
                    End If
                End ForAll
                aiv_checkPersonIsValid = true
            End If
        End If
    
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm hoping someone on this site can offer some help. I have a page
Can someone offer some help with my problem please? I have the following code:
Hopefully someone has been down this road before and can offer some sound advice
Can someone offer me some advice on TeamCity+CI+Deployment So far my it feels rubbish
Let me explain my problem, and hopefully someone can offer some good advice. I
Can someone offer some advice on how to get started with mathematica packages? I
Could someone offer up some advice or point out some blogs/articles that could help
Can someone explain this result to me. The first test succeeds but the second
I am having real trouble trying to deserialize some XML and was hoping someone
I'm trying to return some data based on a series of weeks. This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.