Examples: Save method (NotesDocument - LotusScript®)
- This script creates and saves a new document in the current database.
Because the document is new, there is no chance of conflicting edits,
so the first parameter is False.
Dim session As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Set db = session.CurrentDatabase Set doc = New NotesDocument( db ) doc.Form = "Main Topic" doc.Subject = "Here's a new document" Call doc.Save( False, False )
- This view action script changes the Status item on each document
selected in a view. If someone else edits one of the documents at
the same time, the document is not saved. Instead, a response document
that contains the change to the Status item is created and saved.
Dim session As New NotesSession Dim db As NotesDatabase Dim collection As NotesDocumentCollection Dim doc As NotesDocument Set db = session.CurrentDatabase Set collection = db.UnprocessedDocuments Set doc = collection.GetFirstDocument() While Not(doc Is Nothing) doc.Status = "Processed by view action" Call doc.Save( False, True ) Set doc = collection.GetNextDocument( doc) Wend
- This view action script changes the Status item on each document
selected in a view. If someone else edits one of the documents at
the same time, the document is not saved. For each selected document,
the script displays a message informing the user if the document was
saved or not.
Dim session As New NotesSession Dim db As NotesDatabase Dim collection As NotesDocumentCollection Dim doc As NotesDocument Set db = session.CurrentDatabase Set collection = db.UnprocessedDocuments Set doc = collection.GetFirstDocument() While Not(doc Is Nothing) doc.Status = "Processed by view action" If doc.Save( False, False ) Then Messagebox "Document " & doc.UniversalID & _ " successfully saved" Else Messagebox "Document " & doc.UniversalID & _ " was not saved" End If Set doc = collection.GetNextDocument( doc) Wend
- This script changes the Status item in a document. Because the
first parameter is True, the document gets saved, even if someone
else edits the document while the script runs.
Dim doc As NotesDocument '...set value of doc... doc.Status = "This change gets saved no matter what" Call doc.Save( True, True )