Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Script not working on documents that cannot be edited

I have a form and there are 2 fields - AuthorizedReader which is an Editable Readers field which allow user to enter multi users who can read only and another Authors Editable field called AuthorizedAuthor which allow user to enter multi users who can edit the document. The code below is to prevent the person who is listed in AuthorizedReader from switching to the edit mode and also display a message to let reader know that they are only allow to read.If the person who open this document is in the AuthorizedAuthor field, he/she will be able to edit the document.
But when the code below runs, it will display the message "You can read only" even when the user who open the document is one of the users listed in the AuthorizedAuthor field.

Code:
Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
      Dim curdoc As notesdocument
      Dim item As notesitem
      Dim session As New notessession
      Dim x As Integer
      
      Set curdoc=Source.document
      Set item=curdoc.getfirstitem("AuthorizedAuthor")
      
      If Not (source.editmode) Then
            For x=0 To Ubound(item.values)
                  If session.commonusername<>item.values(x) Then
                        k="no"
                        Msgbox "You can read only!"                                              continue=False
                  Elseif session.commonusername=item.values(x) Then
                        k="yes"
                        continue=True
                        Goto memberofgroup                        
                        End
                                                 memberofgroup:
                        continue=True      
                  End If      
            Next
      End If      
End Sub

Pls advise.
Need this solution urgently.
Thanks.
0
kopibean
Asked:
kopibean
  • 2
  • 2
2 Solutions
 
Bozzie4Commented:
Why do you need this ?  If they only have read access to the document, they can't switch to edit mode !

If they can, they have got MORE than Readers access to the document.  This is generally the case if the people in the Readers access field have higher access then Editor (so Editor, Designer or Manager) or if they are in the Authors field too.ยจ

Anyway, your script will fail because you compare strings that are not the same.  A better solution, if you want to stop higher-than-Editor access people to go into edit mode, is to create an Access Controlled section.  Make it span your entire document (put your entire document into the Access Controlled Section) and use as formula AuthorizedAuthors

Keep in mind that, just as this QueryModeChange stuff, this is NOT a watertight security measure.  People can still create agents to edit values in the document.
If you have the Designer, you can also skip the execution of QueryModeChange, and thus go into edit mode (open the debugger , and stop the script execution in the QueryModeChange).  Since your problem only occurs for higher access users, I bet they may also have a Designer client :-)

cheers,

Tom

0
 
kopibeanAuthor Commented:
Hi Tom,

I do not understand this paragraph-A better solution, if you want to stop higher-than-Editor access people to go into edit mode, is to create an Access Controlled section.  Make it span your entire document (put your entire document into the Access Controlled Section) and use as formula AuthorizedAuthors

Could you kindly explain?
0
 
madheeswarCommented:
I posted response to your previous question Kopibean.

Look into the code which I posted there.
0
 
Bozzie4Commented:
- Create an Access Controlled Section
- Put all your fields into that Access controlled Section
- Use as formula for Editors in the Access Controlled Section, the name of your field, AuthorizedAuthor

And check the Designer help on Access controlled sections :-)

Tom
0
 
kopibeanAuthor Commented:
madheeswar,

I have reply your in my previous question.
Please kindly reply me.Thank you.


Tom,
I have try your solution but users not listed in the AuthorizedAuthor field are able to edit the document.
I'm not sure on this statement ->Use as formula for Editors in the Access Controlled Section, the name of your field, AuthorizedAuthor.

Could you kindly guide me?
Thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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