Error 0?

Hi,

I have created an agent which updates a field on a document depending on what the user chooses from a dialog box. It updates two fields (one called approvals and one called approvalsdisp). For some reason, the approvalsdisp field does not show in the document properties on the default view, only when I go into the document…

Hence, I need to run this agent once the document is open. I would like a messagebox to appear if the user tries to run the document from the view - this works ok, and the messagebox appears. However, when I try to run the agent from within the document, it seems to run through, but then jumps down to the error messagebox and displays an error of ‘0’.

Can anyone tell me what this error means and why it’s appearing even though the agent runs successfully?

My agent is shown below:

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim ws As New NotesUiWorkSpace

Dim tempdoc As NotesDocument

Dim tempdoc2 As Notesdocument

Dim item As NotesItem

Dim nam As NotesName

Dim CommonName As String

Dim item2 As NotesItem

Dim item3 As NotesItem

Dim thisUIDoc As NotesUiDocument

Dim AuditTrail As NotesItem





On Error Goto GenericMessage



Set s = New NotesSession

Set ws = New NotesUIWorkspace

Set db = s.CurrentDatabase

Set thisUIDoc = ws.CurrentDocument

Set Doc = ThisUIDoc.Document

Set tempdoc = db.CreateDocument

Set tempdoc2 = db.CreateDocument

Set item = doc.GetFirstItem( "Approvals" )

Set Item3 = doc.GetFirstItem("ApprovalsDisp")

Set nam = New NotesName(doc.GetItemValue("LeadBriefingOfficer")(0))

CommonName = nam.Common

Set item2 = New NotesItem(tempdoc2, "DialogBoxChoices", "")

Set AuditTrail = Doc.GetFirstItem("AuditTrail")



CurrentDateTime = Format(Now, "dd/mm/yyyy h:nn am/pm")



Forall values3 In doc.LiaisonBranches 

	Call item2.AppendToTextList(values3)

End Forall



Call ws.Dialogbox("CheckboxRetickDialog", True,True, False, False, False, False, "Select the checkbox to retick", tempdoc)



Forall values In tempdoc.SubmissionSelection

	Select Case values		

	Case "Liaison Branch"

		Call ws.Dialogbox("LiaisonBranchList", True,True, False, False, False, False, "Select Liaison Branch", tempdoc2)

		Forall liaisons In tempdoc2.BranchList

			Call item.AppendToTextList("Liaison Branch: " + liaisons)

			Call item3.AppendToTextList("Liaison Branch: " + liaisons)

			Call AuditTrail.AppendToTextList("Liaison Branch: " + liaisons +  " checkbox has been reticked by " + s.commonusername + " at " + CurrentDateTime)

		End Forall

	Case "Lead Branch"

		Call Item.AppendToTextList("Lead Branch: " + doc.LeadBranch(0))

		Call Item3.AppendToTextList("Lead Branch: " + doc.LeadBranch(0))

		Call AuditTrail.AppendToTextList("Lead Branch: " + doc.LeadBranch(0) +  " checkbox has been reticked by " +s.CommonUserName + " at " + CurrentDateTime)

	Case "Deputy Secretary"

		Call item.AppendToTextList("Deputy Secretary")

		Call item3.AppendToTextList("Deputy Secretary")

		Call AuditTrail.AppendToTextList("Deputy Secretary checkbox has been reticked by " +s.CommonUserName+ " at " + CurrentDateTime)

	Case "Author"

		Call item.AppendToTextList("Author: " + CommonName)

		Call item3.AppendToTextList("Author: " + CommonName)

		Call AuditTrail.AppendToTextList("Author: " + CommonName +  " checkbox has been reticked by " +s.CommonUserName+ " at " + CurrentDateTime)

	End Select

End Forall	



Call doc.Save(True, True)



Call thisUIDoc.Close ' close this document so there is no chance of a conflict	

GenericMessage:

Messagebox "Please ensure you have the document open"

Messagebox "Error" & Str(Err) & ": " & Error$

Messagebox Error(), Err(), Erl()

Exit Sub

End Sub

Subject: Error 0?

You need to add Exit Sub after Call thisUIDoc.Close

otherwise you will get the message regardless of whether the code has succeeded or failed

Subject: RE: Error 0?

HI Matt,

That worked, thankyou for the quick response.

Cheers,

Jason