• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

Lotus Script with a slight error (cycle)

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
      Next
      If beuser = 1 Then
      Continue = True
      Else
      Messagebox "Sorry, but you haven't enough right to edit this document.", 64, "Warning!"
      Continue = False
      End If
      End If
      
0
attila01
Asked:
attila01
  • 2
  • 2
1 Solution
 
madheeswarCommented:
sesion.username will give common name.
Instead of usercn = nam.Canonical    
use
usercn = nam.Commonusername

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

to
Set nam = session.CreateName( doc.artname(counter) )
'Set nam = session.CreateName( doc.artname(0) ) ' here it will take the first value only.
0
 
attila01Author Commented:
I deleted the line - Set nam = session.CreateName( doc.artname(0) )
and it seems to work.
But...

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"

   
0
 
madheeswarCommented:
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.
0
 
attila01Author Commented:
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?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now