[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Counter doesn't work (Lotus script)

Posted on 2005-05-10
10
Medium Priority
?
361 Views
Last Modified: 2013-12-18
Some days ago I've already asked this question and gave the points because I thought it would work but I was wrong. Could you have a look at the below issue again?

The Lotus script 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) )
        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
Comment
Question by:attila01
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13967270
Seems strange to me what you're describing. QueryOpen, I assume...

I think you tried only the last one in the list, and indeed he cannot edit the document. This isn't C, so why do you let your counter go to Ubound-1, instead of Ubound?? An array in LS declared as
    Dim myarray(1)
has TWO elements, myarray(0) and myarray(1), Lbound(myarray) yields 0 and Ubound(myarray) yields 1.
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 160 total points
ID: 13967290
Somewhat shorter code:

If doc.Status(0) = 3 Then
    user = session.UserName
    Dim counter As Integer
    Continue= False
    For counter=0 To Ubound(doc.artname)
        Set nam = session.CreateName( doc.artname(counter) )
        usercn = nam.Canonical    
        If user = usercn Then
            Continue= True
            Exit For
        End If
    Next
    If Not Continue Then
        Messagebox "Sorry, but you haven't enough right to edit this document.", 64, "Warning!"
    End If
End If
 
Did you try to use the debugger??
0
 
LVL 19

Assisted Solution

by:madheeswar
madheeswar earned 120 total points
ID: 13967293
I won't think this is the same code from your prev post. Anyway, let me correct it.
If doc.Status(0) = 3 Then
       user = session.UserName
       Dim x As Integer
       Dim beuser As Integer
       beuser = 0
dim item as notesitem
set item=doc.getfirstname("artname")
For x=0 To Ubound(item.values)
Set nam = session.CreateName( item.values(x) )
        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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 13967949
This is not the way the edits are controlled on Lotus Notes Document..You use Authors Type field and populate this field with the names of users who can have edit capability to the document.. But they have to be listed as Authors in the db ACL...so that they are promoted to editor for this document and other where they are explicitly listed by role or username !

~Hemanth
0
 

Author Comment

by:attila01
ID: 13967978
It seems working again, I hope it will work the next days as well. :-))

P.S.
It's a Querymodechange. I wanted to count to the last element, to -1.

Both of the codes were sent me are ok, only I get "Type mismatch" when opening the form for editing. The debugger shows the line:
set item=doc.getfirstname("artname") but it lets me proceed.
 
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 13967989
can u place the entire code?

may be u need to keep,
dim doc as notesdocument

set doc=Source.document
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13968473
Hi Madhees,

GetFirstName?? Is that a new method?

Better use

    Dim v As Variant

    v= doc.artname
    Forall vi In v
   
etc...

Sjef ;)
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 13968735
oh.. sorry.
Nice find Sjef.

it should be set item=doc.getfirstitem("artname")

Thanks Sjef.
0
 
LVL 15

Expert Comment

by:Bozzie4
ID: 13971042
Use an Authors field like Hemantha says   !! What you are doing, is not 'security' - ANY user can start the debugger, stop the execution of the code, and he's in....

(or alternatively, open the document directly in edit mode (CTRL-E in the view), since that will bypass your Querymodechange code too)

Tom
0
 

Author Comment

by:attila01
ID: 13975806
Thanks guys for the info
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

872 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