Reputation: 95
Why do i get "Document command not available error" when i trying to execute an approve action for a form. Its like a flow of approval cycle. This error occurs only for the last approver. When clicked on approve by last approver this error occurs. and the document is not getting approved. And on rejecting a different error message like "Notesdocument-cannot locate field" occurs but the document is rejected on pressing Ok. Can anybody help me please. below is the code for approve action
Sub Click(Source As Button)
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc = w.currentdocument
process = True
approveapplication
gprocess = False
uidoc.Save
uidoc.Refresh
End Sub
and for reject action:
Sub Click(Source As Button)
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc = w.currentdocument
process = False
rejectapplication
gprocess = False
uidoc.Save
uidoc.Refresh
End Sub
The above action is fine for previous approvers. Please help
Upvotes: 2
Views: 4563
Reputation: 9551
"Document command not available" error means you're trying to access or do something in the wrong mode. You need to check that you are in edit mode before you can call uidoc.save. Your Approve code should look like this.
Sub Click(Source As Button)
On Error GoTo errHandle
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc = w.currentdocument
If Not uidoc.EditMode Then
uidoc.EditMode = TRUE
End If
process =True
approveapplication
gprocess = FALSE
uidoc.Save
Exit Sub
errHandle:
Messagebox Lsi_info(2) + ": Error " + Str(Err) + " - " + Error(Err) + ", at line " + Str(Erl)
Exit Sub
End Sub
You shouldn't call uidoc.refresh after calling save or the user will most likely be prompted to save the document again on document close even when there are no changes. Check the notes designer help for information about uidoc.save and uidoc.editmode. Also, note the error handling, error handling will help you pinpoint problems like this.
The "Reject" action problem may be occur if you're accessing a field not visible on the form. Again, add the error handling, and it will be alot easier to trouble shoot.
Upvotes: 4
Reputation: 1
I process massive data from LotusNotes databases and this happen to me all the time.
Contrary to other answers, in my case, the reason was different: seems calling .Edit returns control too soon... and next command (e.g., SelectAll) is not possible to perform, as the document is not fully opened for editing.
Solution... is sipmle. I have added small Sleep (1000ms), so that the document has enough time, and everything works fine.
Upvotes: 0
Reputation: 14628
This error usually seems to happen in cases where the UI classes try to perform an operation and the back-end security enforcement blocks the operation. If the code in your approveapplication function is making changes to the back-end NotesDocument object, especially changes to any reader or author names fields, that could explain it. If that's not it, I have seen cases where an extension manager plugin module for a 3rd party product that integrates with the Notes client caused this error.
Upvotes: 0