A customized Mail database has a system configuration form which includes an action button to enable or disable an agent that sends an automated response. The agent has the ‘Allow user activation’ attribute set.
Access to the system configuration form is restricted to users in an [Admin] role, who also have Editor access to the database and all additional access privileges set in the ACL. Such users can change the agent status once (either enable or disable it) using the action button, but subsequent attempts result in a ‘You are not authorized to perform that operation’ error at the line agt.Save below. After someone with Designer/Manager access to the database clicks the action button, effectively re-signing the agent, the [Admin] users can enable/disable the agent, but again only once before the same error occurs.
The action button code is:
Sub Click(Source As Button)
Dim sess As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim itm As NotesItem
Dim agt As NotesAgent
Dim strTxt As String
Set db = sess.CurrentDatabase
Set agt = db.GetAgent("AutoResponse")
Set doc = ws.CurrentDocument.Document
If agt.IsEnabled Then
agt.IsEnabled = False
Call doc.ReplaceItemValue("AutoReplyStatus", "Off")
Else
Call doc.ReplaceItemValue("AutoReplyStatus", "On")
agt.IsEnabled = True
End If
Call agt.Save
Set itm = doc.GetFirstItem("AutoReplyStatusHistory")
strTxt = doc.GetItemValue("AutoReplyStatus")(0)
strTxt = strTxt & " - " & Format(Now(), "General Date") & " - " & sess.CommonUserName
Call itm.AppendToTextList(strTxt)
Call ws.CurrentDocument.Refresh
Call ws.CurrentDocument.Save
End Sub
Thanks in advance for any ideas on preventing the error message and enabling/disabling the agent as required.
Steve.