Script error

Hi all,

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

pls tell me where i am wrong.

thanxs

Subject: script error

Dim session As New NotesSessionDim ws As New NotesUIWorkspace

Dim uidoc as notesuidocument

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 uidoc=w.currentdocument

set doc=uidoc.document

Set db = session.CurrentDatabase

Set coll = db.UnprocessedDocuments If doc.DocStatus(0) = “Locked” Then…error showing here Call doc.FieldSetText(“DocStatus”,“0”)

Call uidoc.FieldAppendText(“History”,Chr(13) + history1)

Call uidoc.Refresh Call doc.save(True,False)

Call uiview.View.Refresh

Call ws.ViewRefresh

End If

Try this , may be i missed something bcoz i m busy , u focus on ur front end classes and its property mand method . before using always set objects.

RIshi

Subject: script error

Thanxs Rishi for quick answer.I canunderstand you condition.I am trying yaar.it is not working.I am trying.

Subject: script error

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