How can I Give the possibility to unlock the document for the role Admin

The document is lock for everybody but i would like that the role Admin can unlock the document if they want . how can i do

this is the code

Sub Querymodechange(Source As Notesuidocument, Continue As Variant)

If source.fieldgettext("Approved")="Treated"  Then 

	Messagebox "This document is arranged and cannot be edited"

	continue=False

End If

What code i add to allow this ?

Thanks you .

Subject: how can I Give the possibility to unlock the document for the role Admin

If you are using the built-in document locking, you can create a LotusScript agent that only your Admin role people can see/run. Then you can add an action in the view that calls that agent.runonserver and specifies the doc to unlock.

Hope this makes sense - I could share code if needed.

Subject: RE: how can I Give the possibility to unlock the document for the role Admin

YES it is a good idea with an action button simple it arange me to unblock the document if i want to … Can you give me the simple code i can write in my button to unblock the document .

M Thanks .

Subject: RE: how can I Give the possibility to unlock the document for the role Admin

The action button could look something like this (This is bare minimum, there are better ways to handle the selection of which doc to run the agent against)

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim s As New NotesSession

Dim agent As NotesAgent



Set agent = s.CurrentDatabase.GetAgent("MyUnlocker")

Call agent.RunOnServer(ws.CurrentDocument.Document.NoteID)

End Sub

The agent then doesn’t need to be much more than:

Sub Initialize

Dim doc As NotesDocument

Dim s As New NotesSession



Set doc = s.CurrentDatabase.GetDocumentByID(s.CurrentAgent.ParameterDocId)

Call doc.UnLock

End Sub

The key is to have the agent run as someone with Manager access to the database, and to change the security setting for who can view/run the agent.

Subject: RE: how can I Give the possibility to unlock the document for the role Admin

it says object variable no set ??i write exactly your code … and there are an error , can you help me ?