Check if a document is readonly for current user in LotusScript


Option Public
Option Declare

Const wAPIModule = "NNOTES"

Declare Private Function NSFNoteGetInfo Lib wAPIModule Alias "NSFNoteGetInfo" _
( ByVal hNote As Long, ByVal note_member As Integer, value_ptr As Any) As Integer

'Get/Set the note flags (WORD). See NOTE_FLAG_xxx.
Const NOTE_FLAGS = 7

' From the C API:
' The NOTE_FLAG_READONLY bit indicates that the note is Read-Only for the current user.
' If a note contains an author names field, and the name of the user opening the document
' is not included in the author names field list, then  the NOTE_FLAG_READONLY bit is set
' in the note header data when that user opens the note.

' True If document cannot be updated
Const NOTE_FLAG_READONLY = 1


Function isReadOnly(doc As NotesDocument) As Boolean
	Dim T(1) As Integer
	Dim errCode As Integer
	
	errCode = NSFNoteGetInfo(doc.Handle, NOTE_FLAGS, T)
	
	If errCode <> 0 Then
		Error "NSFNoteGetInfo failed with error " + CStr(errCode)
	End If
	
	If (t(0) and NOTE_FLAG_READONLY) = NOTE_FLAG_READONLY Then
		isReadOnly = True
	Else
		isReadOnly = False
	End If
End Function
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...