Lotus Script with a slight error (cycle)

Posted on 2005-05-05
Last Modified: 2013-12-18
I have a Lotus script which is working but it can see only one (the first) name in the Field.
There is a field (artname) that contains 6 names.
All 6 users should be allowed to edit the document but despite the cycle only the first name has access to the document.
Can you tell me what's wrong with it?
Here is the script:

If doc.Status(0) = 3 Then
       user = session.UserName
       Dim counter As Integer
       Dim beuser As Integer
       beuser = 0
For counter=0 To Ubound(doc.artname)-1
Set nam = session.CreateName( doc.artname(counter) )
Set nam = session.CreateName( doc.artname(0) )
         usercn = nam.Canonical      
      If user = usercn Then
      beuser = 1
Exit For
End If
      If beuser = 1 Then
      Continue = True
      Messagebox "Sorry, but you haven't enough right to edit this document.", 64, "Warning!"
      Continue = False
      End If
      End If
Question by:attila01
    LVL 19

    Accepted Solution

    sesion.username will give common name.
    Instead of usercn = nam.Canonical    
    usercn = nam.Commonusername

    and also
    Set nam = session.CreateName( doc.artname(counter) )
    Set nam = session.CreateName( doc.artname(0) )

    Set nam = session.CreateName( doc.artname(counter) )
    'Set nam = session.CreateName( doc.artname(0) ) ' here it will take the first value only.

    Author Comment

    I deleted the line - Set nam = session.CreateName( doc.artname(0) )
    and it seems to work.

    when I replaced usercn = nam.Canonical with usercn = nam.Commonusername (or nam.CommonUserName ) I get an error message:" Data not saved due to an error message"

    LVL 19

    Expert Comment

    U need to compare with the same name formats .. thats what I mean.

    Change user to common name or canonical.. Its upto u and it depends on how you are stroring the values in the field.

    Hope it is clear.

    Author Comment

    Not quite clear but I give you the points because the cycle works.

    Must I use -usercn = nam.Commonusername- or I might as well use it?

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

      In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
    This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now