Subject: RE: Clear web session
Hi,
Here is the entire code for locking the document.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim doc2 As NotesDocument
Dim username As String
Dim curruser As Variant
Dim wholocked As String
On Error Goto whoops
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
curruser = Evaluate({ @Name([CN];@UserName) }, doc)
username = curruser(0)
'following step is done because the user could have opened the doc and only hit the edit button a few minutes later
'by which time another user could have opened and edited/locked the same doc
Set doc2 = db.GetDocumentByUNID(doc.UniversalID)
If Not doc2 Is Nothing Then
If doc2.HasItem( "isLocked" ) Then
If doc2.isLocked(0) = "Locked" Then
If doc2.HasItem( "WhoLocked") Then
wholocked = doc2.WhoLocked(0)
If wholocked = username Then
'open in edit mode
'the person who locked it is trying to edit it, so allow this
Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?EditDocument]")
Else
'open in read mode
'the person other than the person who locked it is trying to edit it, so do not allow this
Call LockedMessage(wholocked)
Goto cleanexit
Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?OpenDocument]")
End If
Else
'open in read mode
'system problem as there is no person assigned to the WhoLocked field, so do not allow this
Call LockedMessage(wholocked)
Goto cleanexit
Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?OpenDocument]")
End If
Else
'set locked
'not locked so set to locked
doc2.isLocked = "Locked"
doc2.WhoLocked = username
Call doc2.Save(True, False)
Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?EditDocument]")
End If
Else
'set locked
'not locked so set to locked
doc2.isLocked = "Locked"
doc2.WhoLocked = username
Call doc2.Save(True, False)
Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?EditDocument]")
End If
End If
cleanexit:
Exit Sub
Whoops:
Dim strErrMsg
Dim strMsg
strMsg = Err & " " & Error$ & " Line " & Erl & " in " & Lsi_info(2)
strErrMsg = "<HR>Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|
strErrMsg = strErrMsg + |<br>Please report this to <a href="mailto:x09731@arrowpointcap.com?Subject=Doc Locking Problem?Body=| + strMsg + |">Your Name"</a><HR>|
Print strErrMsg
Exit Sub
End Sub
The edit event is in a subform and on clicking the edit button this agent is triggered thru formula @command([toolsrunmacro]; “weblock”)
If its possible to clear session pls do let me know or do I have to change my approach.