I have a button that allows users to approve the document. I’d like the users to be able to use the button in either read or edit mode (although I think it’ll be used in read mode most of the time). Below is the code that I have in the button and it works fine in edit mode but not in read mode.
The “Call ApproveDoc(doc)” line of code is a subroutine that adds the current user to the “CurrentApprovers” group, sets the Status field to “Approved”, and adds a line to the “ApprovalHistory” field. This subroutine is also used in the QuerySave event so if the user is in the Approvers group, the document is automatically approved.
Does anyone have any suggestions?
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim uiDoc As NotesUIDocument
Dim doc As NotesDocument
Dim answer As Variant, hasNotApproved As Variant
Set db = session.CurrentDatabase
Set uiDoc = workspace.CurrentDocument
Set doc = uiDoc.Document
hasNotApproved = Evaluate(|!@IsMember(@Name([CN]; @UserName); CurrentApprovers)|, curDoc)
If hasNotApproved(0) Then
answer = workspace.Prompt(PROMPT_YESNO, “Confirmation”, “Are you sure that you want to approve this document?”)
If answer = 1 Then
Call ApproveDoc(doc)
Call doc.Save(True, False)
Else 'if answer is No, then exit
Exit Sub
End If
Else
Msgbox “You’ve already approved this document.”, 0 + 16, “Already Approved”
Exit Sub
End If