Lotus Script Issue witt names

Hello experts,

Once again I am having some issues with Lotusscript, I am scheduled to take a class end of April, I am hoping it will cut down on these type questions.
Here is a script being used in one of our apps. (This was created before I came into the picture):

Sub Postopen(Source As Notesuidocument)
      Const ELUREPID = "85256A6C004C8E88"
      Dim session As New notessession
      Dim db As New notesdatabase("","")
      Dim thisdb As notesdatabase
      Dim doc As notesdocument
      Dim view As notesview
      Dim entry As notesviewentry
      Dim uname As String
      Dim sdept As String      
      Dim smanager As String
      Dim stitle As String
      Dim sphone As String
      Dim sdb As String
      Dim sserver As String
      Dim s1 As String
      Dim s2 As String
      Dim stat As String
      Dim sroles As String
      uname = session.username
      Set thisdb = session.currentdatabase
      sserver = thisdb.server
      If (source.isnewdoc) Then
            If db.OpenByReplicaID(  sserver, ELUREPID ) Then
                  Set view = db.getview("Lookup")
                  Set entry = view.getentrybykey(uname)
                  If (entry Is Nothing) Then
                        Set view = db.getview("Lookup2")
                        uname = session.commonUserName
                        Set entry = view.getentrybykey(uname)
                  End If
                  If Not(entry Is Nothing) Then
                        Set doc = entry.document
                        Call source.fieldsettext("Dept",doc.DeptTitle(0))      
                        Call source.fieldsettext("Title",doc.Description(0))
                        Call source.fieldsettext("Phone",doc.Extension(0))      
                        smanager = doc.Supervisor(0)
                        If Instr(smanager, "(") > 0 Then
                              s1 = Left$(smanager, Instr(smanager,",")-1)
                              s2 = Trim$(Mid$(smanager,Len(s1)+2))
                              smanager = Trim$(Left$(s2,Instr(s2,"(")-1)) +" "+Trim$(s1)
                              s1 = Left$(smanager, Instr(smanager,",")-1)
                              's2 = Right$(smanager,Instr(smanager,",")-2)
                              s2 = Trim$(Mid$(smanager,Len(s1)+2))
                              smanager = s2+" "+s1
                        End If
                        Call source.fieldsettext("Manager",smanager)
                  End If
            End If
            Call source.refresh
            Call source.gotofield("VPN_DateNeeded")
      End If
      If source.isnewdoc Then
            Call source.collapseAllSections
            Call source.expandAllSections
      End If
End Sub

The script populates certain fields in a form, I am figuring based on username, however the application that it is using (ELU) will not populate fileds for users who's names don't match exactly, let me explain, the ELU app uses nicknames instead of usernames, there is a field in ELU that contains the username which I imagine is how the script gets the other data but for some names it will not populate all fields. If the user name is Ray and the nick name on ELU matches then it will populate however if the username is Raymond and the nickname is Ray it will not. What I need if for this script to populate the fields even if the nickname is soemthing else. Can this be done?
Ray PadillaIT DirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this, but it's a risk to match partial names...

change the line
        Set entry = view.getentrybykey(uname)
to this:
Set entry = view.getentrybykey(uname,false)

Sjef BosmanGroupware ConsultantCommented:
False is already the default value...

The code tries to find a document in the Lookup-view based on the current user's username (with format CN=John Doe/O=ACME). If there's no such document, the view Lookup2 is opened to search for the common username (like John Doe). Only if either document is found, some fields in the form are populated. That's what the code says.

Nicknames are out of the question, I'd say. The only solid information you can get are the full username and the common username. The views Lookup and Lookup2 should be designed using these usernames. Otherwise, it will never work. Unless, of course, you create an additional lookup-view to find a nickname for a username...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PadillaIT  DirectorAuthor Commented:
Thanks Sjef, I looked at the views and of course you are correct, now how do I make it work with an additional view with the nicknames? Or better yet how can i make it look at the username then IF there is a nickname use that instead?
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Sjef BosmanGroupware ConsultantCommented:
So you want to add the nicknames somewhere? In what database? There's no NotesSession.nickname available. You need therefore code like
    get the standard Lookup view
    try to find the username
    if not found then
        get the alternate Lookup2 view
        try to find the common username
        if not found then
            get the Nickname view
            find the username based on nickname
            get the standard Lookup view again
            then try to find the username just found in the Nickname view
        end if
    end if

Is that it?

Just a question: is the nickname already used everywhere in that application?? Not good... You'd better translate a nickname into a proper username already in the form, before it is saved.
Ray PadillaIT  DirectorAuthor Commented:
Let me get back to you on this one, I have brought this up to the managers and it seems that the nickname thing may be going away....
Sjef BosmanGroupware ConsultantCommented:
Brilliant!! :-D
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.