actually i am not able to change the field status “locked” to “0”.Always same error "object variable not set."I have to do this operation from view.My button is view and i written a agent on that button.here is script…
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uiview As NotesUIView
Dim db As NotesDatabase
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Dim history1 As String
Dim answer As Integer
Set uiview = ws.CurrentView
Set db = session.CurrentDatabase
Set coll = db.UnprocessedDocuments
If doc.DocStatus(0) = "Locked" Then...error showing here
Call doc.FieldSetText("DocStatus","0")
Call doc.FieldAppendText("History",Chr(13) + history1)
Call doc.Refresh
Call doc.save(True,False)
Call uiview.View.Refresh
Call ws.ViewRefresh
End If
You are mixing frontendclassess with backendclasses (NotesDocument vs. NotesUIDocument)
if it is an agent that runs on selected documents do it like this:
Dim session As New notesSession
Dim db As notesDatabase
Dim coll As notesDocumentCollection
Dim doc As notesDocument
Dim tmpdoc As notesDocument
Dim item As notesItem
Set db = session.currentDatabase
Set coll = db.unprocessedDocuments
Set doc = coll.getFirstDocument
While Not doc Is Nothing
Set tmpdoc = coll.GetNextDocument(doc)
If doc.GetItemValue("DocStatus")(0) = "Locked" Then
Msgbox "ERROR"
Else
Call doc.ReplaceItemValue("DocStatus", "0")
Set item = doc.GetFirstItem("History")
Call item.AppendToTextList("My history string")
Call doc.Save(True, True)
End If
Set doc = tmpdoc
Wend