I am creating document and saving in Lotus Script.I am getting the following error:
Notes error: You cannot update or delete documents since you are not listed as an allowable Author for this document.
I wrote the following script in Quersave event:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc , doc1, doc2 As NotesDocument
Dim workspace As New NotesUIWorkspace
Dim count, nextnum As Integer
Dim itemAuthors As NotesItem
Dim itemAuthor As NotesItem
Set db = session.CurrentDatabase
Set view = db.GetView( "SeqNumber" )
Set doc = view.GetFirstDocument
Set doc2 = source.Document
Set itemAuthors = doc.ReplaceItemValue(“DocAuthor”,doc2.UName(0))
itemAuthors.IsAuthors = True
If doc2.ID(0) = "" Then
nextnum= doc.SeqNumber(0) + 1
doc.SeqNumber = nextnum
doc2.ID = nextnum
Call doc.Save( False, False ): Getting error at this point.
End If
Default access to dB is Author.
Please let me know why I am getting this error.
Thanks in advance.
Subject: Creating document in Lotus Script: Access error
You are not creating the sequence number document – you are attempting to edit an existing document. For that, you (and your users) need to be an “allowable Author”, which means that your “everybody” group should be listed in an Authors field on the document.
There are a couple of other problems as well – you have your declarations wrong on two lines. This line:
Dim doc , doc1, doc2 As NotesDocument
does not declare three NotesDocument variables. It actually does the same as this:
Dim doc As Variant
Dim doc1 As Variant
Dim doc2 As NotesDocument
To declare three NotesDocument variables on one line, you need to do this:
Dim doc As NotesDocument, doc1 As NotesDocument, doc2 As NotesDocument
The “As Type” part is required for every variable – it does not apply to the whole line. Any term missing the “As Type” is being declared as a Variant.
Subject: RE: Creating document in Lotus Script: Access error
Thank you for the response.
In Form properties in under Who can create documents with this form, I have selected ‘All Authors and above’ and default database access is Author.
In the DocAuthor(Authors) field I tried with DocAuthor as default Value and with ‘*’ also.
Please let me know if I am missing anything.
Thank you.
Subject: RE: Creating document in Lotus Script: Access error
Who can create documents is beside the point. Your script does not create a document. It tries to change an existing document.
You say “In the DocAuthor(Authors) field I tried with DocAuthor as default Value and with ‘*’ also.” It doesn’t matter what changes you make to the form since you are not using the form to edit the document. The document does not contain an Authors field (or if it does, it doesn’t contain a value that would let people edit the document). Changing the form does not change this fact about the document. You have to edit the document to add the new Authors field to it.
“*” should work for the Authors field value.